Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-05-27 08:00:04
Exec Total Coverage
Lines: 1790 4300 41.6%
Functions: 131 350 37.4%
Branches: 958 2730 35.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include "combos.h"
67 #include <fmt/format.h>
68
69 #ifdef __EMSCRIPTEN__
70 #include "base/emscripten_utils.h"
71 #endif
72
73 extern FFScript FFCore;
74 extern bool Playing;
75 int32_t sfx_voice[WAV_COUNT];
76 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
77 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
78
79 extern byte monochrome_console;
80
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82835 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 80614 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 80158 times.
✓ Branch 3 taken 82379 times.
82835 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 d[i].dp2 = get_zc_font(font_lfont_l);
254 }
255 else if(!bigfontproc)
256 {
257 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
258 }
259
260 // Make checkboxes work
261 if(d[i].proc == jwin_check_proc)
262 d[i].proc = jwin_checkfont_proc;
263 else if(d[i].proc == jwin_radio_proc)
264 d[i].proc = jwin_radiofont_proc;
265 }
266
267 jwin_center_dialog(d);
268 }
269
270
271 /**********************************/
272 /******** System functions ********/
273 /**********************************/
274
275 static char cfg_sect[] = "zeldadx"; //We need to rename this.
276 static char ctrl_sect[] = "Controls";
277 static char sfx_sect[] = "Volume";
278
279 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
280 {
281 return D_O_K;
282 }
283
284 bool is_reserved_key(int c)
285 {
286 switch(c)
287 {
288 case KEY_ESC:
289 return true;
290 }
291 return false;
292 }
293 bool is_reserved_keycombo(int c, int modflag)
294 {
295 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
296 return true;
297 return false;
298 }
299 bool checkcheat(Cheat cheat)
300 {
301 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
302 return true; //Main key pressed
303 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
304 return true; //Alt key pressed
305 return false;
306 }
307 33 void load_default_cheatkeys()
308 {
309 33 memset(cheatkeys, 0, sizeof(cheatkeys));
310 33 cheatkeys[Cheat::Life][0] = KEY_H;
311 33 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
312 33 cheatkeys[Cheat::Magic][0] = KEY_M;
313 33 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
314 33 cheatkeys[Cheat::Rupies][0] = KEY_R;
315 33 cheatkeys[Cheat::Bombs][0] = KEY_B;
316 33 cheatkeys[Cheat::Arrows][0] = KEY_A;
317 33 cheatkeys[Cheat::Clock][0] = KEY_I;
318 33 cheatkeys[Cheat::Walls][0] = KEY_F11;
319 33 cheatkeys[Cheat::Fast][0] = KEY_Q;
320 33 cheatkeys[Cheat::Light][0] = KEY_L;
321 33 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
322 33 cheatkeys[Cheat::Kill][0] = KEY_K;
323 33 cheatkeys[Cheat::GoTo][0] = KEY_G;
324 33 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
325 33 cheatkeys[Cheat::ShowL0][0] = KEY_0;
326 33 cheatkeys[Cheat::ShowL1][0] = KEY_1;
327 33 cheatkeys[Cheat::ShowL2][0] = KEY_2;
328 33 cheatkeys[Cheat::ShowL3][0] = KEY_3;
329 33 cheatkeys[Cheat::ShowL4][0] = KEY_4;
330 33 cheatkeys[Cheat::ShowL5][0] = KEY_5;
331 33 cheatkeys[Cheat::ShowL6][0] = KEY_6;
332 33 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
333 33 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
334 33 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
335 33 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
336 33 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
337 33 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
338 33 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
339 33 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
340 33 }
341 33 void load_game_configs()
342 {
343 33 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
344 33 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
345 33 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
346 33 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
347 33 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
348 33 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
349 33 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
350 33 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
351 33 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
352 33 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
353 33 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
354 33 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
355 33 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
356 33 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
357 33 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
358
359 //cheat modifier keya
360 33 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
361 33 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
362 33 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
363 33 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
364
365 //cheat keys
366 33 load_default_cheatkeys();
367 char buf[256];
368
2/2
✓ Branch 0 taken 1155 times.
✓ Branch 1 taken 33 times.
1188 for(size_t q = 1; q < Cheat::Last; ++q)
369 {
370
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if(!bindable_cheat((Cheat)q)) continue;
371 1155 std::string cheatname = cheat_to_string((Cheat)q);
372
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 util::lowerstr(cheatname);
373 1155 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
374
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
375 1155 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
376
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
377 1155 }
378
379
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
380 joystick_index = 0;
381
382 33 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
383 33 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
384 33 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
385 33 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
386 33 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
387 33 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
388 33 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
389 33 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
390 33 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
391 33 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
392
393 33 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
394 33 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
395 33 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
396 33 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
397
398 33 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
399 33 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
400 33 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
401 33 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
402 33 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
403 33 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
404 33 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
405 33 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
406 33 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
407 33 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
408 33 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
409
410 33 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
411 33 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
412 33 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
413 33 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
414
415 33 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
416
417 33 digi_volume = zc_get_config(sfx_sect,"digi",248);
418 33 midi_volume = zc_get_config(sfx_sect,"midi",255);
419 33 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
420 33 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
421 33 pan_style = zc_get_config(sfx_sect,"pan",1);
422 // 1 <= zcmusic_bufsz <= 128
423 33 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
424 33 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
425 33 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
426 33 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
427 33 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
428 33 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
429 33 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
430 #ifdef __EMSCRIPTEN__
431 if (em_is_mobile()) NameEntryMode = 2;
432 #endif
433 33 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
434 33 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
435 33 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
436 33 title_version = zc_get_config(cfg_sect,"title",2);
437 33 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
438 33 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
439
440 //default - scale x2, 640 x 480
441 33 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
442 33 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
443 33 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
444 33 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
445 33 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
446 33 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
447 33 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
448
449 33 loadlast = zc_get_config(cfg_sect,"load_last",0);
450
451 33 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
452
453 33 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
454
455 33 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
456 33 info_opacity = zc_get_config("zc","debug_info_opacity",255);
457 #ifdef _WIN32
458 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
461 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
462
463 // This one's for Aero
464 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
465
466 // And this one fixes patches unloading on some MIDI setups
467 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
468 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
469 #else //UNIX
470 33 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
471 33 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
472 33 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
473 #endif
474 33 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
475 33 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
476
477 33 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
478
479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(strlen(qstdir)==0)
480 {
481 33 getcwd(qstdir,2048);
482 33 fix_filename_case(qstdir);
483 33 fix_filename_slashes(qstdir);
484 33 put_backslash(qstdir);
485 33 }
486 else
487 {
488 chop_path(qstdir);
489 }
490
491 33 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
492 33 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
493 33 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
494 33 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
495 33 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
496 33 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
497 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
498 33 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
499 33 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
500 33 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
501 33 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
502 33 }
503
504 void save_control_configs(bool kb)
505 {
506 if(kb)
507 {
508 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
509 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
510 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
511 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
512
513 if (!replay_is_replaying())
514 {
515 zc_set_config(ctrl_sect,"key_a",Akey);
516 zc_set_config(ctrl_sect,"key_b",Bkey);
517 zc_set_config(ctrl_sect,"key_s",Skey);
518 zc_set_config(ctrl_sect,"key_l",Lkey);
519 zc_set_config(ctrl_sect,"key_r",Rkey);
520 zc_set_config(ctrl_sect,"key_p",Pkey);
521 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
522 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
523 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
524 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
525 zc_set_config(ctrl_sect,"key_up", DUkey);
526 zc_set_config(ctrl_sect,"key_down", DDkey);
527 zc_set_config(ctrl_sect,"key_left", DLkey);
528 zc_set_config(ctrl_sect,"key_right",DRkey);
529 }
530 }
531 else
532 {
533 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
534 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
535 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
536 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
537 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
538 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
539 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
540 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
541 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
542 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
543 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
544 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
545 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
546 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
547
548 zc_set_config(ctrl_sect,"btn_a",Abtn);
549 zc_set_config(ctrl_sect,"btn_b",Bbtn);
550 zc_set_config(ctrl_sect,"btn_s",Sbtn);
551 zc_set_config(ctrl_sect,"btn_m",Mbtn);
552 zc_set_config(ctrl_sect,"btn_l",Lbtn);
553 zc_set_config(ctrl_sect,"btn_r",Rbtn);
554 zc_set_config(ctrl_sect,"btn_p",Pbtn);
555 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
556 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
557 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
558 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
559
560 zc_set_config(ctrl_sect,"btn_up",DUbtn);
561 zc_set_config(ctrl_sect,"btn_down",DDbtn);
562 zc_set_config(ctrl_sect,"btn_left",DLbtn);
563 zc_set_config(ctrl_sect,"btn_right",DRbtn);
564 }
565 }
566
567 void save_cheatkeys()
568 {
569 char buf[256];
570 for(size_t q = 1; q < Cheat::Last; ++q)
571 {
572 if(!bindable_cheat((Cheat)q)) continue;
573 std::string cheatname = cheat_to_string((Cheat)q);
574 util::lowerstr(cheatname);
575 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
576 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
577 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
578 if(cheatkeys[q][1])
579 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
580 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
581 }
582 }
583
584 void save_game_configs()
585 {
586 packfile_password("");
587
588 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
589
590 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
591 {
592 int o_window_x, o_window_y;
593 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
594 zc_set_config(cfg_sect,"window_x",o_window_x);
595 zc_set_config(cfg_sect,"window_y",o_window_y);
596 }
597
598 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
599 {
600 double monitor_scale = zc_get_monitor_scale();
601 window_width = al_get_display_width(all_get_display()) / monitor_scale;
602 window_height = al_get_display_height(all_get_display()) / monitor_scale;
603 zc_set_config(cfg_sect,"window_width",window_width);
604 zc_set_config(cfg_sect,"window_height",window_height);
605 }
606
607 zc_set_config(cfg_sect,"load_last",loadlast);
608 chop_path(qstdir);
609 zc_set_config(cfg_sect,qst_dir_name,qstdir);
610 zc_set_config("SAVEFILE","save_filename",save_file_name);
611 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
612
613 flush_config_file();
614 #ifdef __EMSCRIPTEN__
615 em_sync_fs();
616 #endif
617 }
618
619 //----------------------------------------------------------------
620
621 // Timers
622
623 29078 void fps_callback()
624 {
625 29078 lastfps=framecnt;
626 29078 dword tempsecs = fps_secs;
627 29078 ++tempsecs;
628 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
629 29078 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
630 29078 ++fps_secs;
631 29078 framecnt=0;
632 29078 }
633
634 END_OF_FUNCTION(fps_callback)
635
636 33 int32_t Z_init_timers()
637 {
638 static bool didit = false;
639 const static char *err_str = "Couldn't allocate timer";
640 33 err_str = err_str; //Unused variable warning
641
642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(didit)
643 return 1;
644
645 33 didit = true;
646
647 LOCK_VARIABLE(lastfps);
648 LOCK_VARIABLE(framecnt);
649 LOCK_FUNCTION(fps_callback);
650
651
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
652 return 0;
653
654 33 return 1;
655 33 }
656
657 void Z_remove_timers()
658 {
659 remove_int(fps_callback);
660 }
661
662 //----------------------------------------------------------------
663
664 void go()
665 {
666 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
667 }
668
669 void comeback()
670 {
671 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
672 }
673
674 void dump_pal(BITMAP *dest)
675 {
676 for(int32_t i=0; i<256; i++)
677 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
678 }
679
680 //----------------------------------------------------------------
681
682 int game_mouse_index = ZCM_BLANK;
683 static bool system_mouse = false;
684 28 bool sys_mouse()
685 {
686 28 system_mouse = true;
687 28 return MouseSprite::set(ZCM_NORMAL);
688 }
689 457 bool game_mouse()
690 {
691 457 system_mouse = false;
692 457 return MouseSprite::set(game_mouse_index);
693 }
694 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
695 {
696 if(!bmp)
697 return;
698 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
699 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
700 if(bmp->w == scaledw && bmp->h == scaledh)
701 user_scale = false;
702 if(user_scale || sys_recolor)
703 {
704 if(!user_scale) scale = 1;
705 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
706 if(user_scale)
707 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
708 else
709 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
710 if(sys_recolor)
711 recolor_mouse(tmpbmp);
712 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
713 destroy_bitmap(tmpbmp);
714 }
715 else
716 {
717 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
718 }
719 }
720
721 //Handles converting the mouse sprite from the .dat file
722 33 void recolor_mouse(BITMAP* bmp)
723 {
724
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 33 times.
561 for(int32_t x = 0; x < bmp->w; ++x)
725 {
726
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 528 times.
8976 for(int32_t y = 0; y < bmp->h; ++y)
727 {
728 8448 int32_t color = getpixel(bmp, x, y);
729
5/5
✓ Branch 0 taken 5742 times.
✓ Branch 1 taken 627 times.
✓ Branch 2 taken 726 times.
✓ Branch 3 taken 759 times.
✓ Branch 4 taken 594 times.
8448 switch(color)
730 {
731 case dvc(1):
732 627 color = jwin_pal[jcCURSORMISC];
733 627 break;
734 case dvc(2):
735 726 color = jwin_pal[jcCURSOROUTLINE];
736 726 break;
737 case dvc(3):
738 759 color = jwin_pal[jcCURSORLIGHT];
739 759 break;
740 case dvc(5):
741 594 color = jwin_pal[jcCURSORDARK];
742 594 break;
743 default:
744 5742 continue;
745 }
746 2706 putpixel(bmp, x, y, color);
747 2706 }
748 528 }
749 33 }
750 33 void load_mouse()
751 {
752 33 system_pal();
753 33 MouseSprite::set(-1);
754 33 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
755 33 int32_t sz = 16*scale;
756
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 for(int32_t j = 0; j < 1; ++j)
757 {
758 33 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
759
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(zcmouse[j])
760 destroy_bitmap(zcmouse[j]);
761 33 zcmouse[j] = create_bitmap_ex(8,sz,sz);
762 33 clear_bitmap(zcmouse[j]);
763 33 clear_bitmap(tmpbmp);
764 33 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
765 33 recolor_mouse(tmpbmp);
766
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(sz!=16)
767 33 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
768 else
769 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
770 33 destroy_bitmap(tmpbmp);
771 33 }
772 33 zc_set_palette(*hw_palette);
773
774 33 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
775 33 clear_bitmap(blankmouse);
776
777 33 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
778 33 MouseSprite::assign(ZCM_BLANK, blankmouse);
779 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
780
781 //Reload the mouse
782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(system_mouse)
783 sys_mouse();
784 33 else game_mouse();
785
786 33 destroy_bitmap(blankmouse);
787 33 game_pal();
788 33 }
789
790 // sets the video mode and initializes the palette and mouse sprite
791 33 bool game_vid_mode(int32_t mode,int32_t wait)
792 {
793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
794 {
795 return false;
796 }
797
798 33 scrx = (resx-320)>>1;
799 33 scry = (resy-240)>>1;
800
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
801 33 zcmouse[q] = NULL;
802 33 load_mouse();
803
804
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 33 times.
561 for(int32_t i=240; i<256; i++)
805 528 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
806
807 33 zc_set_palette(RAMpal);
808 33 clear_to_color(screen,BLACK);
809
810 33 rest(wait);
811 33 return true;
812 33 }
813
814 7 void null_quest()
815 {
816 char qstdat_string[2048];
817 7 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
818 7 strcat(qstdat_string,"#NESQST_NEW_QST");
819
820 #ifdef __EMSCRIPTEN__
821 // The quest template data file is not included because it's really big and isn't really needed
822 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
823 // which is much smaller.
824 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
825 #endif
826
827 7 byte skip_flags[4] = { 0 };
828
829 7 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,skip_flags,0,false);
830 7 }
831
832 // TODO remove
833 7 void init_NES_mode()
834 {
835 7 null_quest();
836 7 }
837
838 //----------------------------------------------------------------
839
840 qword trianglelines[16]=
841 {
842 0x0000000000000000ULL,
843 0xFD00000000000000ULL,
844 0xFDFD000000000000ULL,
845 0xFDFDFD0000000000ULL,
846 0xFDFDFDFD00000000ULL,
847 0xFDFDFDFDFD000000ULL,
848 0xFDFDFDFDFDFD0000ULL,
849 0xFDFDFDFDFDFDFD00ULL,
850 0xFDFDFDFDFDFDFDFDULL,
851 0x00FDFDFDFDFDFDFDULL,
852 0x0000FDFDFDFDFDFDULL,
853 0x000000FDFDFDFDFDULL,
854 0x00000000FDFDFDFDULL,
855 0x0000000000FDFDFDULL,
856 0x000000000000FDFDULL,
857 0x00000000000000FDULL,
858 };
859
860 word screen_triangles[28][32];
861 /*
862 qword triangles[4][16]= //[direction][value]
863 {
864 {
865 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
866 },
867 {
868 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
869 },
870 {
871 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
872 },
873 {
874 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
875 }
876 };
877 */
878
879
880 /*
881 byte triangles[4][16][8]= //[direction][value][line]
882 {
883 {
884 {
885 0, 0, 0, 0, 0, 0, 0, 0
886 },
887 {
888 1, 0, 0, 0, 0, 0, 0, 0
889 },
890 {
891 2, 1, 0, 0, 0, 0, 0, 0
892 },
893 {
894 3, 2, 1, 0, 0, 0, 0, 0
895 },
896 {
897 4, 3, 2, 1, 0, 0, 0, 0
898 },
899 {
900 5, 4, 3, 2, 1, 0, 0, 0
901 },
902 {
903 6, 5, 4, 3, 2, 1, 0, 0
904 },
905 {
906 7, 6, 5, 4, 3, 2, 1, 0
907 },
908 {
909 8, 7, 6, 5, 4, 3, 2, 1
910 },
911 {
912 8, 8, 7, 6, 5, 4, 3, 2
913 },
914 {
915 8, 8, 8, 7, 6, 5, 4, 3
916 },
917 {
918 8, 8, 8, 8, 7, 6, 5, 4
919 },
920 {
921 8, 8, 8, 8, 8, 7, 6, 5
922 },
923 {
924 8, 8, 8, 8, 8, 8, 7, 6
925 },
926 {
927 8, 8, 8, 8, 8, 8, 8, 7
928 },
929 {
930 8, 8, 8, 8, 8, 8, 8, 8
931 }
932 },
933 {
934 {
935 0, 0, 0, 0, 0, 0, 0, 0
936 },
937 {
938 15, 0, 0, 0, 0, 0, 0, 0
939 },
940 {
941 14, 15, 0, 0, 0, 0, 0, 0
942 },
943 {
944 13, 14, 15, 0, 0, 0, 0, 0
945 },
946 {
947 12, 13, 14, 15, 0, 0, 0, 0
948 },
949 {
950 11, 12, 13, 14, 15, 0, 0, 0
951 },
952 {
953 10, 11, 12, 13, 14, 15, 0, 0
954 },
955 {
956 9, 10, 11, 12, 13, 14, 15, 0
957 },
958 {
959 8, 9, 10, 11, 12, 13, 14, 15
960 },
961 {
962 8, 8, 9, 10, 11, 12, 13, 14
963 },
964 {
965 8, 8, 8, 9, 10, 11, 12, 13
966 },
967 {
968 8, 8, 8, 8, 9, 10, 11, 12
969 },
970 {
971 8, 8, 8, 8, 8, 9, 10, 11
972 },
973 {
974 8, 8, 8, 8, 8, 8, 9, 10
975 },
976 {
977 8, 8, 8, 8, 8, 8, 8, 9
978 },
979 {
980 8, 8, 8, 8, 8, 8, 8, 8
981 }
982 },
983 {
984 {
985 0, 0, 0, 0, 0, 0, 0, 0
986 },
987 {
988 0, 0, 0, 0, 0, 0, 0, 1
989 },
990 {
991 0, 0, 0, 0, 0, 0, 1, 2
992 },
993 {
994 0, 0, 0, 0, 0, 1, 2, 3
995 },
996 {
997 0, 0, 0, 0, 1, 2, 3, 4
998 },
999 {
1000 0, 0, 0, 1, 2, 3, 4, 5
1001 },
1002 {
1003 0, 0, 1, 2, 3, 4, 5, 6
1004 },
1005 {
1006 0, 1, 2, 3, 4, 5, 6, 7
1007 },
1008 {
1009 1, 2, 3, 4, 5, 6, 7, 8
1010 },
1011 {
1012 2, 3, 4, 5, 6, 7, 8, 8
1013 },
1014 {
1015 3, 4, 5, 6, 7, 8, 8, 8
1016 },
1017 {
1018 4, 5, 6, 7, 8, 8, 8, 8
1019 },
1020 {
1021 5, 6, 7, 8, 8, 8, 8, 8
1022 },
1023 {
1024 6, 7, 8, 8, 8, 8, 8, 8
1025 },
1026 {
1027 7, 8, 8, 8, 8, 8, 8, 8
1028 },
1029 {
1030 8, 8, 8, 8, 8, 8, 8, 8
1031 }
1032 },
1033 {
1034 {
1035 0, 0, 0, 0, 0, 0, 0, 0
1036 },
1037 {
1038 0, 0, 0, 0, 0, 0, 0, 15
1039 },
1040 {
1041 0, 0, 0, 0, 0, 0, 15, 14
1042 },
1043 {
1044 0, 0, 0, 0, 0, 15, 14, 13
1045 },
1046 {
1047 0, 0, 0, 0, 15, 14, 13, 12
1048 },
1049 {
1050 0, 0, 0, 15, 14, 13, 12, 11
1051 },
1052 {
1053 0, 0, 15, 14, 13, 12, 11, 10
1054 },
1055 {
1056 0, 15, 14, 13, 12, 11, 10, 9
1057 },
1058 {
1059 15, 14, 13, 12, 11, 10, 9, 8
1060 },
1061 {
1062 14, 13, 12, 11, 10, 9, 8, 8
1063 },
1064 {
1065 13, 12, 11, 10, 9, 8, 8, 8
1066 },
1067 {
1068 12, 11, 10, 9, 8, 8, 8, 8
1069 },
1070 {
1071 11, 10, 9, 8, 8, 8, 8, 8
1072 },
1073 {
1074 10, 9, 8, 8, 8, 8, 8, 8
1075 },
1076 {
1077 9, 8, 8, 8, 8, 8, 8, 8
1078 },
1079 {
1080 8, 8, 8, 8, 8, 8, 8, 8
1081 }
1082 }
1083 };
1084 */
1085
1086
1087
1088 /*
1089 for (int32_t blockrow=0; blockrow<30; ++i)
1090 {
1091 for (int32_t linerow=0; linerow<8; ++i)
1092 {
1093 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1094 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1095 {
1096 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1097 ++triangleline;
1098 }
1099 }
1100 }
1101 */
1102
1103 // the ULL suffixes are to prevent this warning:
1104 // warning: integer constant is too large for "int32_t" type
1105
1106 qword triangles[4][16][8]= //[direction][value][line]
1107 {
1108 {
1109 {
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL,
1117 0x0000000000000000ULL
1118 },
1119 {
1120 0xFD00000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL,
1127 0x0000000000000000ULL
1128 },
1129 {
1130 0xFDFD000000000000ULL,
1131 0xFD00000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL
1138 },
1139 {
1140 0xFDFDFD0000000000ULL,
1141 0xFDFD000000000000ULL,
1142 0xFD00000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL
1148 },
1149 {
1150 0xFDFDFDFD00000000ULL,
1151 0xFDFDFD0000000000ULL,
1152 0xFDFD000000000000ULL,
1153 0xFD00000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL
1158 },
1159 {
1160 0xFDFDFDFDFD000000ULL,
1161 0xFDFDFDFD00000000ULL,
1162 0xFDFDFD0000000000ULL,
1163 0xFDFD000000000000ULL,
1164 0xFD00000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL
1168 },
1169 {
1170 0xFDFDFDFDFDFD0000ULL,
1171 0xFDFDFDFDFD000000ULL,
1172 0xFDFDFDFD00000000ULL,
1173 0xFDFDFD0000000000ULL,
1174 0xFDFD000000000000ULL,
1175 0xFD00000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL
1178 },
1179 {
1180 0xFDFDFDFDFDFDFD00ULL,
1181 0xFDFDFDFDFDFD0000ULL,
1182 0xFDFDFDFDFD000000ULL,
1183 0xFDFDFDFD00000000ULL,
1184 0xFDFDFD0000000000ULL,
1185 0xFDFD000000000000ULL,
1186 0xFD00000000000000ULL,
1187 0x0000000000000000ULL
1188 },
1189 {
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFD00ULL,
1192 0xFDFDFDFDFDFD0000ULL,
1193 0xFDFDFDFDFD000000ULL,
1194 0xFDFDFDFD00000000ULL,
1195 0xFDFDFD0000000000ULL,
1196 0xFDFD000000000000ULL,
1197 0xFD00000000000000ULL
1198 },
1199 {
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFD00ULL,
1203 0xFDFDFDFDFDFD0000ULL,
1204 0xFDFDFDFDFD000000ULL,
1205 0xFDFDFDFD00000000ULL,
1206 0xFDFDFD0000000000ULL,
1207 0xFDFD000000000000ULL
1208 },
1209 {
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFD00ULL,
1214 0xFDFDFDFDFDFD0000ULL,
1215 0xFDFDFDFDFD000000ULL,
1216 0xFDFDFDFD00000000ULL,
1217 0xFDFDFD0000000000ULL
1218 },
1219 {
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFD00ULL,
1225 0xFDFDFDFDFDFD0000ULL,
1226 0xFDFDFDFDFD000000ULL,
1227 0xFDFDFDFD00000000ULL
1228 },
1229 {
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFD00ULL,
1236 0xFDFDFDFDFDFD0000ULL,
1237 0xFDFDFDFDFD000000ULL
1238 },
1239 {
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFD00ULL,
1247 0xFDFDFDFDFDFD0000ULL
1248 },
1249 {
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFDFDULL,
1257 0xFDFDFDFDFDFDFD00ULL
1258 },
1259 {
1260 0xFDFDFDFDFDFDFDFDULL,
1261 0xFDFDFDFDFDFDFDFDULL,
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0xFDFDFDFDFDFDFDFDULL,
1267 0xFDFDFDFDFDFDFDFDULL
1268 }
1269 },
1270 {
1271 {
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL,
1279 0x0000000000000000ULL
1280 },
1281 {
1282 0x00000000000000FDULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL,
1289 0x0000000000000000ULL
1290 },
1291 {
1292 0x000000000000FDFDULL,
1293 0x00000000000000FDULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL
1300 },
1301 {
1302 0x0000000000FDFDFDULL,
1303 0x000000000000FDFDULL,
1304 0x00000000000000FDULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL
1310 },
1311 {
1312 0x00000000FDFDFDFDULL,
1313 0x0000000000FDFDFDULL,
1314 0x000000000000FDFDULL,
1315 0x00000000000000FDULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL
1320 },
1321 {
1322 0x000000FDFDFDFDFDULL,
1323 0x00000000FDFDFDFDULL,
1324 0x0000000000FDFDFDULL,
1325 0x000000000000FDFDULL,
1326 0x00000000000000FDULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL
1330 },
1331 {
1332 0x0000FDFDFDFDFDFDULL,
1333 0x000000FDFDFDFDFDULL,
1334 0x00000000FDFDFDFDULL,
1335 0x0000000000FDFDFDULL,
1336 0x000000000000FDFDULL,
1337 0x00000000000000FDULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL
1340 },
1341 {
1342 0x00FDFDFDFDFDFDFDULL,
1343 0x0000FDFDFDFDFDFDULL,
1344 0x000000FDFDFDFDFDULL,
1345 0x00000000FDFDFDFDULL,
1346 0x0000000000FDFDFDULL,
1347 0x000000000000FDFDULL,
1348 0x00000000000000FDULL,
1349 0x0000000000000000ULL
1350 },
1351 {
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0x00FDFDFDFDFDFDFDULL,
1354 0x0000FDFDFDFDFDFDULL,
1355 0x000000FDFDFDFDFDULL,
1356 0x00000000FDFDFDFDULL,
1357 0x0000000000FDFDFDULL,
1358 0x000000000000FDFDULL,
1359 0x00000000000000FDULL
1360 },
1361 {
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0x00FDFDFDFDFDFDFDULL,
1365 0x0000FDFDFDFDFDFDULL,
1366 0x000000FDFDFDFDFDULL,
1367 0x00000000FDFDFDFDULL,
1368 0x0000000000FDFDFDULL,
1369 0x000000000000FDFDULL
1370 },
1371 {
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0x00FDFDFDFDFDFDFDULL,
1376 0x0000FDFDFDFDFDFDULL,
1377 0x000000FDFDFDFDFDULL,
1378 0x00000000FDFDFDFDULL,
1379 0x0000000000FDFDFDULL
1380 },
1381 {
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0x00FDFDFDFDFDFDFDULL,
1387 0x0000FDFDFDFDFDFDULL,
1388 0x000000FDFDFDFDFDULL,
1389 0x00000000FDFDFDFDULL
1390 },
1391 {
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0xFDFDFDFDFDFDFDFDULL,
1397 0x00FDFDFDFDFDFDFDULL,
1398 0x0000FDFDFDFDFDFDULL,
1399 0x000000FDFDFDFDFDULL
1400 },
1401 {
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0xFDFDFDFDFDFDFDFDULL,
1408 0x00FDFDFDFDFDFDFDULL,
1409 0x0000FDFDFDFDFDFDULL
1410 },
1411 {
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL,
1418 0xFDFDFDFDFDFDFDFDULL,
1419 0x00FDFDFDFDFDFDFDULL
1420 },
1421 {
1422 0xFDFDFDFDFDFDFDFDULL,
1423 0xFDFDFDFDFDFDFDFDULL,
1424 0xFDFDFDFDFDFDFDFDULL,
1425 0xFDFDFDFDFDFDFDFDULL,
1426 0xFDFDFDFDFDFDFDFDULL,
1427 0xFDFDFDFDFDFDFDFDULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL
1430 }
1431 },
1432 {
1433 {
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0x0000000000000000ULL,
1439 0x0000000000000000ULL,
1440 0x0000000000000000ULL,
1441 0x0000000000000000ULL
1442 },
1443 {
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0x0000000000000000ULL,
1449 0x0000000000000000ULL,
1450 0x0000000000000000ULL,
1451 0xFD00000000000000ULL
1452 },
1453 {
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0x0000000000000000ULL,
1458 0x0000000000000000ULL,
1459 0x0000000000000000ULL,
1460 0xFD00000000000000ULL,
1461 0xFDFD000000000000ULL
1462 },
1463 {
1464 0x0000000000000000ULL,
1465 0x0000000000000000ULL,
1466 0x0000000000000000ULL,
1467 0x0000000000000000ULL,
1468 0x0000000000000000ULL,
1469 0xFD00000000000000ULL,
1470 0xFDFD000000000000ULL,
1471 0xFDFDFD0000000000ULL
1472 },
1473 {
1474 0x0000000000000000ULL,
1475 0x0000000000000000ULL,
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0xFD00000000000000ULL,
1479 0xFDFD000000000000ULL,
1480 0xFDFDFD0000000000ULL,
1481 0xFDFDFDFD00000000ULL
1482 },
1483 {
1484 0x0000000000000000ULL,
1485 0x0000000000000000ULL,
1486 0x0000000000000000ULL,
1487 0xFD00000000000000ULL,
1488 0xFDFD000000000000ULL,
1489 0xFDFDFD0000000000ULL,
1490 0xFDFDFDFD00000000ULL,
1491 0xFDFDFDFDFD000000ULL
1492 },
1493 {
1494 0x0000000000000000ULL,
1495 0x0000000000000000ULL,
1496 0xFD00000000000000ULL,
1497 0xFDFD000000000000ULL,
1498 0xFDFDFD0000000000ULL,
1499 0xFDFDFDFD00000000ULL,
1500 0xFDFDFDFDFD000000ULL,
1501 0xFDFDFDFDFDFD0000ULL
1502 },
1503 {
1504 0x0000000000000000ULL,
1505 0xFD00000000000000ULL,
1506 0xFDFD000000000000ULL,
1507 0xFDFDFD0000000000ULL,
1508 0xFDFDFDFD00000000ULL,
1509 0xFDFDFDFDFD000000ULL,
1510 0xFDFDFDFDFDFD0000ULL,
1511 0xFDFDFDFDFDFDFD00ULL
1512 },
1513 {
1514 0xFD00000000000000ULL,
1515 0xFDFD000000000000ULL,
1516 0xFDFDFD0000000000ULL,
1517 0xFDFDFDFD00000000ULL,
1518 0xFDFDFDFDFD000000ULL,
1519 0xFDFDFDFDFDFD0000ULL,
1520 0xFDFDFDFDFDFDFD00ULL,
1521 0xFDFDFDFDFDFDFDFDULL
1522 },
1523 {
1524 0xFDFD000000000000ULL,
1525 0xFDFDFD0000000000ULL,
1526 0xFDFDFDFD00000000ULL,
1527 0xFDFDFDFDFD000000ULL,
1528 0xFDFDFDFDFDFD0000ULL,
1529 0xFDFDFDFDFDFDFD00ULL,
1530 0xFDFDFDFDFDFDFDFDULL,
1531 0xFDFDFDFDFDFDFDFDULL
1532 },
1533 {
1534 0xFDFDFD0000000000ULL,
1535 0xFDFDFDFD00000000ULL,
1536 0xFDFDFDFDFD000000ULL,
1537 0xFDFDFDFDFDFD0000ULL,
1538 0xFDFDFDFDFDFDFD00ULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL
1542 },
1543 {
1544 0xFDFDFDFD00000000ULL,
1545 0xFDFDFDFDFD000000ULL,
1546 0xFDFDFDFDFDFD0000ULL,
1547 0xFDFDFDFDFDFDFD00ULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL,
1551 0xFDFDFDFDFDFDFDFDULL
1552 },
1553 {
1554 0xFDFDFDFDFD000000ULL,
1555 0xFDFDFDFDFDFD0000ULL,
1556 0xFDFDFDFDFDFDFD00ULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL,
1559 0xFDFDFDFDFDFDFDFDULL,
1560 0xFDFDFDFDFDFDFDFDULL,
1561 0xFDFDFDFDFDFDFDFDULL
1562 },
1563 {
1564 0xFDFDFDFDFDFD0000ULL,
1565 0xFDFDFDFDFDFDFD00ULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL,
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL
1572 },
1573 {
1574 0xFDFDFDFDFDFDFD00ULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL,
1580 0xFDFDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL
1582 },
1583 {
1584 0xFDFDFDFDFDFDFDFDULL,
1585 0xFDFDFDFDFDFDFDFDULL,
1586 0xFDFDFDFDFDFDFDFDULL,
1587 0xFDFDFDFDFDFDFDFDULL,
1588 0xFDFDFDFDFDFDFDFDULL,
1589 0xFDFDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL
1592 }
1593 },
1594 {
1595 {
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x0000000000000000ULL,
1601 0x0000000000000000ULL,
1602 0x0000000000000000ULL,
1603 0x0000000000000000ULL
1604 },
1605 {
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x0000000000000000ULL,
1611 0x0000000000000000ULL,
1612 0x0000000000000000ULL,
1613 0x00000000000000FDULL
1614 },
1615 {
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x0000000000000000ULL,
1620 0x0000000000000000ULL,
1621 0x0000000000000000ULL,
1622 0x00000000000000FDULL,
1623 0x000000000000FDFDULL
1624 },
1625 {
1626 0x0000000000000000ULL,
1627 0x0000000000000000ULL,
1628 0x0000000000000000ULL,
1629 0x0000000000000000ULL,
1630 0x0000000000000000ULL,
1631 0x00000000000000FDULL,
1632 0x000000000000FDFDULL,
1633 0x0000000000FDFDFDULL
1634 },
1635 {
1636 0x0000000000000000ULL,
1637 0x0000000000000000ULL,
1638 0x0000000000000000ULL,
1639 0x0000000000000000ULL,
1640 0x00000000000000FDULL,
1641 0x000000000000FDFDULL,
1642 0x0000000000FDFDFDULL,
1643 0x00000000FDFDFDFDULL
1644 },
1645 {
1646 0x0000000000000000ULL,
1647 0x0000000000000000ULL,
1648 0x0000000000000000ULL,
1649 0x00000000000000FDULL,
1650 0x000000000000FDFDULL,
1651 0x0000000000FDFDFDULL,
1652 0x00000000FDFDFDFDULL,
1653 0x000000FDFDFDFDFDULL
1654 },
1655 {
1656 0x0000000000000000ULL,
1657 0x0000000000000000ULL,
1658 0x00000000000000FDULL,
1659 0x000000000000FDFDULL,
1660 0x0000000000FDFDFDULL,
1661 0x00000000FDFDFDFDULL,
1662 0x000000FDFDFDFDFDULL,
1663 0x0000FDFDFDFDFDFDULL
1664 },
1665 {
1666 0x0000000000000000ULL,
1667 0x00000000000000FDULL,
1668 0x000000000000FDFDULL,
1669 0x0000000000FDFDFDULL,
1670 0x00000000FDFDFDFDULL,
1671 0x000000FDFDFDFDFDULL,
1672 0x0000FDFDFDFDFDFDULL,
1673 0x00FDFDFDFDFDFDFDULL
1674 },
1675 {
1676 0x00000000000000FDULL,
1677 0x000000000000FDFDULL,
1678 0x0000000000FDFDFDULL,
1679 0x00000000FDFDFDFDULL,
1680 0x000000FDFDFDFDFDULL,
1681 0x0000FDFDFDFDFDFDULL,
1682 0x00FDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL
1684 },
1685 {
1686 0x000000000000FDFDULL,
1687 0x0000000000FDFDFDULL,
1688 0x00000000FDFDFDFDULL,
1689 0x000000FDFDFDFDFDULL,
1690 0x0000FDFDFDFDFDFDULL,
1691 0x00FDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL
1694 },
1695 {
1696 0x0000000000FDFDFDULL,
1697 0x00000000FDFDFDFDULL,
1698 0x000000FDFDFDFDFDULL,
1699 0x0000FDFDFDFDFDFDULL,
1700 0x00FDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL
1704 },
1705 {
1706 0x00000000FDFDFDFDULL,
1707 0x000000FDFDFDFDFDULL,
1708 0x0000FDFDFDFDFDFDULL,
1709 0x00FDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL,
1713 0xFDFDFDFDFDFDFDFDULL
1714 },
1715 {
1716 0x000000FDFDFDFDFDULL,
1717 0x0000FDFDFDFDFDFDULL,
1718 0x00FDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL,
1722 0xFDFDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL
1724 },
1725 {
1726 0x0000FDFDFDFDFDFDULL,
1727 0x00FDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL,
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL
1734 },
1735 {
1736 0x00FDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL,
1742 0xFDFDFDFDFDFDFDFDULL,
1743 0xFDFDFDFDFDFDFDFDULL
1744 },
1745 {
1746 0xFDFDFDFDFDFDFDFDULL,
1747 0xFDFDFDFDFDFDFDFDULL,
1748 0xFDFDFDFDFDFDFDFDULL,
1749 0xFDFDFDFDFDFDFDFDULL,
1750 0xFDFDFDFDFDFDFDFDULL,
1751 0xFDFDFDFDFDFDFDFDULL,
1752 0xFDFDFDFDFDFDFDFDULL,
1753 0xFDFDFDFDFDFDFDFDULL
1754 }
1755 }
1756 };
1757
1758 int32_t black_opening_count=0;
1759 int32_t black_opening_x,black_opening_y;
1760 int32_t black_opening_shape;
1761
1762 1134 int32_t choose_opening_shape()
1763 {
1764 // First, count how many bits are set
1765 1134 int32_t numBits=0;
1766 int32_t bitCounter;
1767
1768
2/2
✓ Branch 0 taken 5670 times.
✓ Branch 1 taken 1134 times.
6804 for(int32_t i=0; i<bosMAX; i++)
1769 {
1770
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 1350 times.
5670 if(COOLSCROLL&(1<<i))
1771 1350 numBits++;
1772 5670 }
1773
1774 // Shouldn't happen...
1775
1/2
✓ Branch 0 taken 1134 times.
✗ Branch 1 not taken.
1134 if(numBits==0)
1776 return bosCIRCLE;
1777
1778 // Pick a bit
1779 1134 bitCounter=zc_rand()%numBits+1;
1780
1781
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 26 times.
1426 for(int32_t i=0; i<bosMAX; i++)
1782 {
1783 // If this bit is set, decrement the bit counter
1784
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1264 times.
1400 if(COOLSCROLL&(1<<i))
1785 1264 bitCounter--;
1786
1787 // When the counter hits 0, return a value based on
1788 // which bit it stopped on.
1789 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1790
2/2
✓ Branch 0 taken 1108 times.
✓ Branch 1 taken 292 times.
1400 if(bitCounter==0)
1791 1108 return i;
1792 292 }
1793
1794 // Shouldn't be necessary, but the compiler might complain, at least
1795 26 return bosCIRCLE;
1796 1134 }
1797
1798 312 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1799 {
1800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
312 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1801
1802 312 int32_t w=256, h=224;
1803 312 int32_t blockrows=28, blockcolumns=32;
1804 312 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1805
1806
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 312 times.
9048 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1807 {
1808
2/2
✓ Branch 0 taken 279552 times.
✓ Branch 1 taken 8736 times.
288288 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1809 {
1810
2/2
✓ Branch 0 taken 148819 times.
✓ Branch 1 taken 130733 times.
279552 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1811 279552 }
1812 8736 }
1813
1814 312 black_opening_count = 66;
1815 312 black_opening_x = x;
1816 312 black_opening_y = y;
1817 312 lensclk = 0;
1818 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1819
1820
1821
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(black_opening_shape == bosFADEBLACK)
1822 {
1823 refreshTints();
1824 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1825 }
1826
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(wait)
1827 {
1828 FFCore.warpScriptCheck();
1829 for(int32_t i=0; i<66; i++)
1830 {
1831 draw_screen(tmpscr);
1832 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1833 advanceframe(true);
1834
1835 if(Quit)
1836 {
1837 break;
1838 }
1839 }
1840 }
1841 312 }
1842
1843 822 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1844 {
1845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 822 times.
822 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1846
1847 822 int32_t w=256, h=224;
1848 822 int32_t blockrows=28, blockcolumns=32;
1849 822 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1850
1851
2/2
✓ Branch 0 taken 23016 times.
✓ Branch 1 taken 822 times.
23838 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1852 {
1853
2/2
✓ Branch 0 taken 736512 times.
✓ Branch 1 taken 23016 times.
759528 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1854 {
1855
2/2
✓ Branch 0 taken 335267 times.
✓ Branch 1 taken 401245 times.
736512 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1856 736512 }
1857 23016 }
1858
1859 822 black_opening_count = -66;
1860 822 black_opening_x = x;
1861 822 black_opening_y = y;
1862 822 lensclk = 0;
1863
1/2
✓ Branch 0 taken 822 times.
✗ Branch 1 not taken.
822 if(black_opening_shape == bosFADEBLACK)
1864 {
1865 refreshTints();
1866 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1867 }
1868
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 627 times.
822 if(wait)
1869 {
1870 627 FFCore.warpScriptCheck();
1871
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 41382 times.
42009 for(int32_t i=0; i<66; i++)
1872 {
1873 41382 draw_screen(tmpscr);
1874 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1875 41382 advanceframe(true);
1876
1877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41382 times.
41382 if(Quit)
1878 {
1879 break;
1880 }
1881 41382 }
1882 627 }
1883 822 }
1884
1885 74844 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1886 {
1887 74844 clear_to_color(tmp_scr,BLACK);
1888 74844 int32_t w=256, h=224;
1889
1890
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 2838 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70488 times.
74844 switch(black_opening_shape)
1891 {
1892 case bosOVAL:
1893 {
1894 858 double new_w=(w/2)+abs(w/2-x);
1895 858 double new_h=(h/2)+abs(h/2-y);
1896 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1897 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1898 858 break;
1899 }
1900
1901 case bosTRIANGLE:
1902 {
1903 660 double new_w=(w/2)+abs(w/2-x);
1904 660 double new_h=(h/2)+abs(h/2-y);
1905 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1906 660 double P2= (PI/2);
1907 660 double P23=(2*PI/3);
1908 660 double P43=(4*PI/3);
1909 660 double Pa= (-4*PI*a/(3*max_a));
1910 660 double angle=P2+Pa;
1911 660 double a0=angle;
1912 660 double a2=angle+P23;
1913 660 double a4=angle+P43;
1914 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1915 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1916 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1917 0);
1918 660 break;
1919 }
1920
1921 case bosSMAS:
1922 {
1923
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 1386 times.
2838 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1924
1925
2/2
✓ Branch 0 taken 79464 times.
✓ Branch 1 taken 2838 times.
82302 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1926 {
1927
2/2
✓ Branch 0 taken 635712 times.
✓ Branch 1 taken 79464 times.
715176 for(int32_t linerow=0; linerow<8; ++linerow)
1928 {
1929 635712 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1930
1931
2/2
✓ Branch 0 taken 20342784 times.
✓ Branch 1 taken 635712 times.
20978496 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1932 {
1933 61028352 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1934
6/6
✓ Branch 0 taken 14117840 times.
✓ Branch 1 taken 6224944 times.
✓ Branch 2 taken 13330568 times.
✓ Branch 3 taken 7012216 times.
✓ Branch 4 taken 7105624 times.
✓ Branch 5 taken 6224944 times.
20342784 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1935 20342784 [linerow];
1936 20342784 ++triangleline;
1937
1938
2/2
✓ Branch 0 taken 17799936 times.
✓ Branch 1 taken 2542848 times.
20342784 if(linerow==0)
1939 {
1940 2542848 }
1941 20342784 }
1942 635712 }
1943 79464 }
1944
1945 2838 break;
1946 }
1947
1948 case bosFADEBLACK:
1949 {
1950 if(black_opening_count<0)
1951 {
1952 black_fade(zc_min(-black_opening_count,63));
1953 }
1954 else if(black_opening_count>0)
1955 {
1956 black_fade(63-zc_max(black_opening_count-3,0));
1957 }
1958 else black_fade(0);
1959 return; //no blitting from tmp_scr!
1960 }
1961
1962 70488 case bosCIRCLE:
1963 default:
1964 {
1965 70488 double new_w=(w/2)+abs(w/2-x);
1966 70488 double new_h=(h/2)+abs(h/2-y);
1967 70488 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1968 //circlefill(tmp_scr,x,y,a<<3,0);
1969 70488 circlefill(tmp_scr,x,y,r,0);
1970 70488 break;
1971 }
1972 }
1973
1974 74844 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1975 74844 }
1976
1977
1978 void black_fade(int32_t fadeamnt)
1979 {
1980 for(int32_t i=0; i < 0xEF; i++)
1981 {
1982 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1983 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1984 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1985 }
1986
1987 refreshpal = true;
1988 }
1989
1990 //----------------------------------------------------------------
1991
1992 32885089 bool item_disabled(int32_t item) //is this item disabled?
1993 {
1994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32885089 times.
32885089 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1995 }
1996
1997 6715675 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1998 {
1999
2/2
✓ Branch 0 taken 80417 times.
✓ Branch 1 taken 6635258 times.
6715675 if(current_item(item_type, true) >=item)
2000 {
2001 80417 return true;
2002 }
2003
2004 6635258 return false;
2005 6715675 }
2006
2007 27682319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
2008 {
2009
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5075885 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3051917 times.
✓ Branch 6 taken 14716964 times.
✓ Branch 7 taken 4802881 times.
✓ Branch 8 taken 34672 times.
27682319 switch(item_type)
2010 {
2011 case itype_bomb:
2012 case itype_sbomb:
2013 {
2014 int32_t itemid = getItemID(itemsbuf, item_type, it);
2015
2016 if(itemid == -1)
2017 return false;
2018
2019 return (game->get_item(itemid));
2020 }
2021
2022 case itype_clock:
2023 {
2024 5075885 int32_t itemid = getItemID(itemsbuf, item_type, it);
2025
2026
2/4
✓ Branch 0 taken 5075885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5075885 times.
✗ Branch 3 not taken.
5075885 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2027 return (game->get_item(itemid));
2028 5075885 return Hero.getClock()?1:0;
2029 }
2030
2031 case itype_key:
2032 return (game->get_keys()>0);
2033
2034 case itype_magiccontainer:
2035 return (game->get_maxmagic()>=game->get_mp_per_block());
2036
2037 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2038 {
2039
1/3
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3051917 switch(it)
2040 {
2041 case -2:
2042 {
2043 for(int32_t i=0; i<MAXLEVELS; i++)
2044 {
2045 if(game->lvlitems[i]&liTRIFORCE)
2046 {
2047 return true;
2048 }
2049 }
2050
2051 return false;
2052 }
2053
2054 case -1:
2055 return (game->lvlitems[dlevel]&liTRIFORCE);
2056
2057 default:
2058
2/4
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3051917 times.
3051917 if(it>=0&&it<MAXLEVELS)
2059 {
2060 3051917 return (game->lvlitems[it]&liTRIFORCE);
2061 }
2062
2063 break;
2064 }
2065
2066 return 0;
2067 }
2068
2069 case itype_map: //it: -2=any, -1=current level, other=that level
2070 {
2071
1/3
✓ Branch 0 taken 14716964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14716964 switch(it)
2072 {
2073 case -2:
2074 {
2075 for(int32_t i=0; i<MAXLEVELS; i++)
2076 {
2077 if(game->lvlitems[i]&liMAP)
2078 {
2079 return true;
2080 }
2081 }
2082
2083 return false;
2084 }
2085
2086 case -1:
2087 return (game->lvlitems[dlevel]&liMAP)!=0;
2088
2089 default:
2090
2/4
✓ Branch 0 taken 14716964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14716964 times.
14716964 if(it>=0&&it<MAXLEVELS)
2091 {
2092 14716964 return (game->lvlitems[it]&liMAP)!=0;
2093 }
2094
2095 break;
2096 }
2097
2098 return 0;
2099 }
2100
2101 case itype_compass: //it: -2=any, -1=current level, other=that level
2102 {
2103
1/3
✓ Branch 0 taken 4802881 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4802881 switch(it)
2104 {
2105 case -2:
2106 {
2107 for(int32_t i=0; i<MAXLEVELS; i++)
2108 {
2109 if(game->lvlitems[i]&liCOMPASS)
2110 {
2111 return true;
2112 }
2113 }
2114
2115 return false;
2116 }
2117
2118 case -1:
2119 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2120
2121 default:
2122
2/4
✓ Branch 0 taken 4802881 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4802881 times.
✗ Branch 3 not taken.
4802881 if(it>=0&&it<MAXLEVELS)
2123 {
2124 4802881 return (game->lvlitems[it]&liCOMPASS)!=0;
2125 }
2126
2127 break;
2128 }
2129 return 0;
2130 }
2131
2132 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2133 {
2134
1/3
✓ Branch 0 taken 34672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
34672 switch(it)
2135 {
2136 case -2:
2137 {
2138 for(int32_t i=0; i<MAXLEVELS; i++)
2139 {
2140 if(game->lvlitems[i]&liBOSSKEY)
2141 {
2142 return true;
2143 }
2144 }
2145
2146 return false;
2147 }
2148
2149 case -1:
2150 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2151
2152 default:
2153
2/4
✓ Branch 0 taken 34672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34672 times.
34672 if(it>=0&&it<MAXLEVELS)
2154 {
2155 34672 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2156 }
2157 break;
2158 }
2159 return 0;
2160 }
2161
2162 default:
2163 //it=(1<<(it-1));
2164 /*if (item_type>=itype_max)
2165 {
2166 system_pal();
2167 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2168 game_pal();
2169
2170 return false;
2171 }*/
2172 int32_t itemid = getItemID(itemsbuf, item_type, it);
2173
2174 if(itemid == -1)
2175 return false;
2176
2177 return game->get_item(itemid);
2178 }
2179 27682319 }
2180
2181
2182 86609834 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2183 {
2184
9/9
✓ Branch 0 taken 5075885 times.
✓ Branch 1 taken 46002754 times.
✓ Branch 2 taken 5075885 times.
✓ Branch 3 taken 5075885 times.
✓ Branch 4 taken 5075885 times.
✓ Branch 5 taken 5075885 times.
✓ Branch 6 taken 5075885 times.
✓ Branch 7 taken 5075885 times.
✓ Branch 8 taken 5075885 times.
86609834 switch(item_type)
2185 {
2186 case itype_clock:
2187 {
2188 5075885 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2189
2190
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5075885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5075885 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2191 return itemsbuf[maxid].fam_type;
2192
2193 5075885 return has_item(itype_clock,1) ? 1 : 0;
2194 }
2195
2196 case itype_key:
2197 5075885 return game->get_keys();
2198
2199 case itype_lkey:
2200 5075885 return game->lvlkeys[get_dlevel()];
2201
2202 case itype_magiccontainer:
2203 5075885 return game->get_maxmagic()/game->get_mp_per_block();
2204
2205 case itype_triforcepiece:
2206 {
2207 5075885 int32_t count=0;
2208
2209
2/2
✓ Branch 0 taken 2598853120 times.
✓ Branch 1 taken 5075885 times.
2603929005 for(int32_t i=0; i<MAXLEVELS; i++)
2210 {
2211 2598853120 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2212 2598853120 }
2213
2214 5075885 return count;
2215 }
2216
2217 case itype_map:
2218 {
2219 5075885 int32_t count=0;
2220
2221
2/2
✓ Branch 0 taken 2598853120 times.
✓ Branch 1 taken 5075885 times.
2603929005 for(int32_t i=0; i<MAXLEVELS; i++)
2222 {
2223 2598853120 count+=(game->lvlitems[i]&liMAP)?1:0;
2224 2598853120 }
2225
2226 5075885 return count;
2227 }
2228
2229 case itype_compass:
2230 {
2231 5075885 int32_t count=0;
2232
2233
2/2
✓ Branch 0 taken 2598853120 times.
✓ Branch 1 taken 5075885 times.
2603929005 for(int32_t i=0; i<MAXLEVELS; i++)
2234 {
2235 2598853120 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2236 2598853120 }
2237
2238 5075885 return count;
2239 }
2240
2241 case itype_bosskey:
2242 {
2243 5075885 int32_t count=0;
2244
2245
2/2
✓ Branch 0 taken 2598853120 times.
✓ Branch 1 taken 5075885 times.
2603929005 for(int32_t i=0; i<MAXLEVELS; i++)
2246 {
2247 2598853120 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2248 2598853120 }
2249
2250 5075885 return count;
2251 }
2252
2253 default:
2254 46002754 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2255
2256
2/2
✓ Branch 0 taken 8708246 times.
✓ Branch 1 taken 37294508 times.
46002754 if(maxid == -1)
2257 37294508 return 0;
2258
2259 8708246 return itemsbuf[maxid].fam_type;
2260 }
2261 86609834 }
2262
2263 79894159 int32_t current_item(int32_t item_type) //item currently being used
2264 {
2265 79894159 return current_item(item_type, true);
2266 }
2267
2268 33 std::map<int32_t, int32_t> itemcache;
2269
2270 // Not actually used by anything at the moment...
2271 void removeFromItemCache(int32_t itemclass)
2272 {
2273 itemcache.erase(itemclass);
2274 }
2275
2276 24261 void flushItemCache()
2277 {
2278 24261 itemcache.clear();
2279
2280 //also fix the active subscreen if items were deleted -DD
2281
1/2
✓ Branch 0 taken 24261 times.
✗ Branch 1 not taken.
24261 if(game != NULL)
2282 {
2283 24261 verifyBothWeapons();
2284 24261 load_Sitems(&QMisc);
2285 24261 }
2286 24261 }
2287
2288 // This is used often, so it should be as direct as possible.
2289 2829168445 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2290 {
2291
2/2
✓ Branch 0 taken 2770715320 times.
✓ Branch 1 taken 58453125 times.
2829168445 if(jinx_check)
2292 {
2293
4/4
✓ Branch 0 taken 38291923 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 34628259 times.
✓ Branch 3 taken 3663664 times.
58453125 if(!(HeroSwordClk() || HeroItemClk()))
2294 34628259 jinx_check = false; //not jinxed
2295 58453125 }
2296
4/4
✓ Branch 0 taken 2804947534 times.
✓ Branch 1 taken 24220911 times.
✓ Branch 2 taken 23650363 times.
✓ Branch 3 taken 2781297171 times.
2829168445 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2297 {
2298 2781297171 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2299
2300
2/2
✓ Branch 0 taken 2768911095 times.
✓ Branch 1 taken 12386076 times.
2781297171 if(res != itemcache.end())
2301 2768911095 return res->second;
2302 12386076 }
2303
2304 60257350 int32_t result = -1;
2305 60257350 int32_t highestlevel = -1;
2306
2307
2/2
✓ Branch 0 taken 15425881600 times.
✓ Branch 1 taken 60257350 times.
15486138950 for(int32_t i=0; i<MAXITEMS; i++)
2308 {
2309
5/6
✓ Branch 0 taken 1197955310 times.
✓ Branch 1 taken 14227926290 times.
✓ Branch 2 taken 17819159 times.
✓ Branch 3 taken 1180136151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17819159 times.
15425881600 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2310 {
2311
4/4
✓ Branch 0 taken 5189638 times.
✓ Branch 1 taken 12629521 times.
✓ Branch 2 taken 1358181 times.
✓ Branch 3 taken 16460978 times.
17819159 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2312 {
2313 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2314
2/2
✓ Branch 0 taken 16460821 times.
✓ Branch 1 taken 157 times.
16460978 if(!checkmagiccost(i))
2315 {
2316
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 145 times.
157 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2317 12 }
2318 16460833 }
2319
6/6
✓ Branch 0 taken 15432428 times.
✓ Branch 1 taken 2386586 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2129898 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 759329 times.
17819014 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2320 {
2321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 759329 times.
759329 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2322 759329 continue;
2323 }
2324
2325
2/2
✓ Branch 0 taken 237660 times.
✓ Branch 1 taken 16822025 times.
17059685 if(itemsbuf[i].fam_type >= highestlevel)
2326 {
2327 16822025 highestlevel = itemsbuf[i].fam_type;
2328 16822025 result=i;
2329 16822025 }
2330 17059685 }
2331 15425122126 }
2332
2333
2/2
✓ Branch 0 taken 23824866 times.
✓ Branch 1 taken 36432484 times.
60257350 if(!jinx_check) //Can't cache jinx_check results
2334 36432484 itemcache[itemtype] = result;
2335 60257350 return result;
2336 2829168445 }
2337
2338 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2339 2805661025 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2340 {
2341 2805661025 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2342
2/2
✓ Branch 0 taken 34945705 times.
✓ Branch 1 taken 2770715320 times.
2805661025 if(!jinx_check) //If not already a jinx-immune-only check...
2343 {
2344 //And the player IS jinxed...
2345
4/4
✓ Branch 0 taken 2750819702 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3611802 times.
✓ Branch 3 taken 2747207900 times.
2770715320 if(HeroSwordClk() || HeroItemClk())
2346 {
2347 //Then do a jinx-immune-only check here
2348 23507420 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2349 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2350 //Should NOT need a compat rule, as this should always return -1 in old quests.
2351
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22404776 times.
23507420 if(ret2 > -1) return ret2;
2352 22404776 }
2353 2769612676 }
2354 2804558381 return ret;
2355 2805661025 }
2356 17662014 int32_t current_item_power(int32_t itemtype)
2357 {
2358 17662014 int32_t result = current_item_id(itemtype,true);
2359
2/2
✓ Branch 0 taken 13152285 times.
✓ Branch 1 taken 4509729 times.
17662014 return (result<0) ? 0 : itemsbuf[result].power;
2360 }
2361
2362 7 int32_t heart_container_id()
2363 {
2364
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2365 {
2366
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2367 {
2368 7 return i;
2369 }
2370 196 }
2371 return -1;
2372 7 }
2373
2374 5075885 int32_t item_tile_mod()
2375 {
2376 5075885 int32_t tile=0;
2377
2378
2/2
✓ Branch 0 taken 1064842 times.
✓ Branch 1 taken 4011043 times.
5075885 if(game->get_bombs())
2379 {
2380 4011043 int32_t itemid = current_item_id(itype_bomb,false);
2381
3/4
✓ Branch 0 taken 3929984 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3929984 times.
4011043 if(itemid > -1 && checkbunny(itemid))
2382 3929984 tile+=itemsbuf[itemid].ltm;
2383 4011043 }
2384
2385
2/2
✓ Branch 0 taken 3905451 times.
✓ Branch 1 taken 1170434 times.
5075885 if(game->get_sbombs())
2386 {
2387 1170434 int32_t itemid = current_item_id(itype_sbomb,false);
2388
3/4
✓ Branch 0 taken 1169006 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1169006 times.
1170434 if(itemid > -1 && checkbunny(itemid))
2389 1169006 tile+=itemsbuf[itemid].ltm;
2390 1170434 }
2391
2392
2/2
✓ Branch 0 taken 4971942 times.
✓ Branch 1 taken 103943 times.
5075885 if(current_item(itype_clock))
2393 {
2394 103943 int32_t itemid =
2395
1/2
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
103943 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2396 ? iClock
2397 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2398
2/4
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103943 times.
103943 if(itemid > -1 && checkbunny(itemid))
2399 103943 tile+=itemsbuf[itemid].ltm;
2400 103943 }
2401
2402
2/2
✓ Branch 0 taken 4029973 times.
✓ Branch 1 taken 1045912 times.
5075885 if(current_item(itype_key))
2403 {
2404 1045912 int32_t itemid =
2405
1/2
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
1045912 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2406 ? iKey
2407 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2408
2/4
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1045912 times.
1045912 if(itemid > -1 && checkbunny(itemid))
2409 1045912 tile+=itemsbuf[itemid].ltm;
2410 1045912 }
2411
2412
2/2
✓ Branch 0 taken 4903354 times.
✓ Branch 1 taken 172531 times.
5075885 if(current_item(itype_lkey))
2413 {
2414 172531 int32_t itemid =
2415
2/2
✓ Branch 0 taken 171621 times.
✓ Branch 1 taken 910 times.
172531 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2416 ? iLevelKey
2417 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2418
2/4
✓ Branch 0 taken 172531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 172531 times.
172531 if(itemid > -1 && checkbunny(itemid))
2419 172531 tile+=itemsbuf[itemid].ltm;
2420 172531 }
2421
2422
2/2
✓ Branch 0 taken 1040409 times.
✓ Branch 1 taken 4035476 times.
5075885 if(current_item(itype_map))
2423 {
2424 4035476 int32_t itemid =
2425
2/2
✓ Branch 0 taken 4034690 times.
✓ Branch 1 taken 786 times.
4035476 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2426 ? iMap
2427 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2428
2/4
✓ Branch 0 taken 4035476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4035476 times.
4035476 if(itemid > -1 && checkbunny(itemid))
2429 4035476 tile+=itemsbuf[itemid].ltm;
2430 4035476 }
2431
2432
2/2
✓ Branch 0 taken 1018527 times.
✓ Branch 1 taken 4057358 times.
5075885 if(current_item(itype_compass))
2433 {
2434 4057358 int32_t itemid =
2435
2/2
✓ Branch 0 taken 3976299 times.
✓ Branch 1 taken 81059 times.
4057358 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2436 ? iCompass
2437 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2438
2/4
✓ Branch 0 taken 4057358 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4057358 times.
4057358 if(itemid > -1 && checkbunny(itemid))
2439 4057358 tile+=itemsbuf[itemid].ltm;
2440 4057358 }
2441
2442
2/2
✓ Branch 0 taken 3206681 times.
✓ Branch 1 taken 1869204 times.
5075885 if(current_item(itype_bosskey))
2443 {
2444 1869204 int32_t itemid =
2445
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2446 ? iBossKey
2447 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2448
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2449 1869204 tile+=itemsbuf[itemid].ltm;
2450 1869204 }
2451
2452
2/2
✓ Branch 0 taken 2920770 times.
✓ Branch 1 taken 2155115 times.
5075885 if(current_item(itype_magiccontainer))
2453 {
2454 2155115 int32_t itemid =
2455
2/2
✓ Branch 0 taken 2062128 times.
✓ Branch 1 taken 92987 times.
2155115 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2456 ? iMagicC
2457 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2458
3/4
✓ Branch 0 taken 2155115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2153245 times.
2155115 if(itemid > -1 && checkbunny(itemid))
2459 2153245 tile+=itemsbuf[itemid].ltm;
2460 2155115 }
2461
2462
2/2
✓ Branch 0 taken 1376592 times.
✓ Branch 1 taken 3699293 times.
5075885 if(current_item(itype_triforcepiece))
2463 {
2464 3699293 int32_t itemid =
2465
1/2
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
3699293 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2466 ? iTriforce
2467 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2468
2/4
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3699293 times.
3699293 if(itemid > -1 && checkbunny(itemid))
2469 3699293 tile+=itemsbuf[itemid].ltm;
2470 3699293 }
2471
2472
2/2
✓ Branch 0 taken 5075885 times.
✓ Branch 1 taken 2598853120 times.
2603929005 for(int32_t i=0; i<itype_max; i++)
2473 {
2474
2/2
✓ Branch 0 taken 2540581376 times.
✓ Branch 1 taken 58271744 times.
2598853120 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2475 {
2476
2/2
✓ Branch 0 taken 1138120 times.
✓ Branch 1 taken 57133624 times.
58271744 switch(i)
2477 {
2478 case itype_bomb:
2479 case itype_sbomb:
2480 case itype_clock:
2481 case itype_key:
2482 case itype_lkey:
2483 case itype_map:
2484 case itype_compass:
2485 case itype_bosskey:
2486 case itype_magiccontainer:
2487 case itype_triforcepiece:
2488 1138120 continue; //already handled
2489 }
2490 57133624 }
2491 2597715000 int32_t itemid = current_item_id(i,false);
2492
2/2
✓ Branch 0 taken 2592639115 times.
✓ Branch 1 taken 5075885 times.
2597715000 if(i == itype_shield)
2493 5075885 itemid = getCurrentShield(false);
2494
2495
4/4
✓ Branch 0 taken 70934807 times.
✓ Branch 1 taken 2526780193 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 70833826 times.
2597715000 if(itemid < 0 || !checkbunny(itemid))
2496 2526881174 continue;
2497
2498 70833826 itemdata const& itm = itemsbuf[itemid];
2499
2500
2/2
✓ Branch 0 taken 66371614 times.
✓ Branch 1 taken 4462212 times.
70833826 switch(itm.family)
2501 {
2502 case itype_shield:
2503
1/2
✓ Branch 0 taken 4462212 times.
✗ Branch 1 not taken.
4462212 if(itm.flags & ITEM_FLAG9) //active shield
2504 {
2505 if(!usingActiveShield(itemid))
2506 {
2507 tile+=itm.misc6; //'Inactive PTM'
2508 continue;
2509 }
2510 }
2511 4462212 break;
2512 }
2513
2514 70833826 tile+=itm.ltm;
2515 70833826 }
2516
2517 5075885 return tile;
2518 }
2519
2520 5075885 int32_t bunny_tile_mod()
2521 {
2522
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 5074015 times.
5075885 if(Hero.BunnyClock())
2523 {
2524 1870 return game->get_bunny_ltm();
2525 }
2526 5074015 return 0;
2527 5075885 }
2528
2529 // Hints are drawn on a separate layer to combo reveals.
2530 16332 void draw_lens_under(BITMAP *dest, bool layer)
2531 {
2532 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2533 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2534 //Lens flag 3: Don't show armos/chest/dive items
2535 //Lens flag 4: Show Raft Paths
2536 //Lens flag 5: Show Invisible Enemies
2537
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2538
2539 16332 int32_t strike_hint_table[11]=
2540 {
2541 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2542 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2543 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2544 };
2545
2546 // int32_t page = tmpscr->cpage;
2547 {
2548 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2549 // int32_t temptimer=0;
2550 16332 int32_t tempitem, tempweapon=0;
2551 16332 strike_hint=strike_hint_table[strike_hint_counter];
2552
2553
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2554 {
2555 492 strike_hint_timer=0;
2556 492 strike_hint_counter=((strike_hint_counter+1)%11);
2557 492 }
2558
2559 16332 ++strike_hint_timer;
2560
2561
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2562 {
2563 2874432 int32_t x = (i & 15) << 4;
2564 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2565 2874432 int32_t tempitemx=-16, tempitemy=-16;
2566 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2567
2568
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2569 {
2570 5748864 int32_t checkflag=0;
2571
2572
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2573 {
2574 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2575 2874432 }
2576 else
2577 {
2578 2874432 checkflag=tmpscr->sflag[i];
2579 }
2580
2581
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2582 {
2583
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2584 {
2585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2586 906 }
2587 else
2588 {
2589 192 checkflag = strike_hint;
2590 }
2591 1098 }
2592
2593
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2594 {
2595 case 0:
2596 case mfZELDA:
2597 case mfPUSHED:
2598 case mfENEMY0:
2599 case mfENEMY1:
2600 case mfENEMY2:
2601 case mfENEMY3:
2602 case mfENEMY4:
2603 case mfENEMY5:
2604 case mfENEMY6:
2605 case mfENEMY7:
2606 case mfENEMY8:
2607 case mfENEMY9:
2608 case mfSINGLE:
2609 case mfSINGLE16:
2610 case mfNOENEMY:
2611 case mfTRAP_H:
2612 case mfTRAP_V:
2613 case mfTRAP_4:
2614 case mfTRAP_LR:
2615 case mfTRAP_UD:
2616 case mfNOGROUNDENEMY:
2617 case mfNOBLOCKS:
2618 case mfSCRIPT1:
2619 case mfSCRIPT2:
2620 case mfSCRIPT3:
2621 case mfSCRIPT4:
2622 case mfSCRIPT5:
2623 case mfSCRIPT6:
2624 case mfSCRIPT7:
2625 case mfSCRIPT8:
2626 case mfSCRIPT9:
2627 case mfSCRIPT10:
2628 case mfSCRIPT11:
2629 case mfSCRIPT12:
2630 case mfSCRIPT13:
2631 case mfSCRIPT14:
2632 case mfSCRIPT15:
2633 case mfSCRIPT16:
2634 case mfSCRIPT17:
2635 case mfSCRIPT18:
2636 case mfSCRIPT19:
2637 case mfSCRIPT20:
2638 case mfPITHOLE:
2639 case mfPITFALLFLOOR:
2640 case mfLAVA:
2641 case mfICE:
2642 case mfICEDAMAGE:
2643 case mfDAMAGE1:
2644 case mfDAMAGE2:
2645 case mfDAMAGE4:
2646 case mfDAMAGE8:
2647 case mfDAMAGE16:
2648 case mfDAMAGE32:
2649 case mfFREEZEALL:
2650 case mfFREZEALLANSFFCS:
2651 case mfFREEZEFFCSOLY:
2652 case mfSCRITPTW1TRIG:
2653 case mfSCRITPTW2TRIG:
2654 case mfSCRITPTW3TRIG:
2655 case mfSCRITPTW4TRIG:
2656 case mfSCRITPTW5TRIG:
2657 case mfSCRITPTW6TRIG:
2658 case mfSCRITPTW7TRIG:
2659 case mfSCRITPTW8TRIG:
2660 case mfSCRITPTW9TRIG:
2661 case mfSCRITPTW10TRIG:
2662 case mfTROWEL:
2663 case mfTROWELNEXT:
2664 case mfTROWELSPECIALITEM:
2665 case mfSLASHPOT:
2666 case mfLIFTPOT:
2667 case mfLIFTORSLASH:
2668 case mfLIFTROCK:
2669 case mfLIFTROCKHEAVY:
2670 case mfDROPITEM:
2671 case mfSPECIALITEM:
2672 case mfDROPKEY:
2673 case mfDROPLKEY:
2674 case mfDROPCOMPASS:
2675 case mfDROPMAP:
2676 case mfDROPBOSSKEY:
2677 case mfSPAWNNPC:
2678 case mfSWITCHHOOK:
2679 case mfSIDEVIEWLADDER:
2680 case mfSIDEVIEWPLATFORM:
2681 case mfNOENEMYSPAWN:
2682 case mfENEMYALL:
2683 case mfNOMIRROR:
2684 case mfUNSAFEGROUND:
2685 case mf168:
2686 case mf169:
2687 case mf170:
2688 case mf171:
2689 case mf172:
2690 case mf173:
2691 case mf174:
2692 case mf175:
2693 case mf176:
2694 case mf177:
2695 case mf178:
2696 case mf179:
2697 case mf180:
2698 case mf181:
2699 case mf182:
2700 case mf183:
2701 case mf184:
2702 case mf185:
2703 case mf186:
2704 case mf187:
2705 case mf188:
2706 case mf189:
2707 case mf190:
2708 case mf191:
2709 case mf192:
2710 case mf193:
2711 case mf194:
2712 case mf195:
2713 case mf196:
2714 case mf197:
2715 case mf198:
2716 case mf199:
2717 case mf200:
2718 case mf201:
2719 case mf202:
2720 case mf203:
2721 case mf204:
2722 case mf205:
2723 case mf206:
2724 case mf207:
2725 case mf208:
2726 case mf209:
2727 case mf210:
2728 case mf211:
2729 case mf212:
2730 case mf213:
2731 case mf214:
2732 case mf215:
2733 case mf216:
2734 case mf217:
2735 case mf218:
2736 case mf219:
2737 case mf220:
2738 case mf221:
2739 case mf222:
2740 case mf223:
2741 case mf224:
2742 case mf225:
2743 case mf226:
2744 case mf227:
2745 case mf228:
2746 case mf229:
2747 case mf230:
2748 case mf231:
2749 case mf232:
2750 case mf233:
2751 case mf234:
2752 case mf235:
2753 case mf236:
2754 case mf237:
2755 case mf238:
2756 case mf239:
2757 case mf240:
2758 case mf241:
2759 case mf242:
2760 case mf243:
2761 case mf244:
2762 case mf245:
2763 case mf246:
2764 case mf247:
2765 case mf248:
2766 case mf249:
2767 case mf250:
2768 case mf251:
2769 case mf252:
2770 case mf253:
2771 case mf254:
2772 case mfEXTENDED:
2773 5706470 break;
2774
2775 case mfPUSHUD:
2776 case mfPUSHLR:
2777 case mfPUSH4:
2778 case mfPUSHU:
2779 case mfPUSHD:
2780 case mfPUSHL:
2781 case mfPUSHR:
2782 case mfPUSHUDNS:
2783 case mfPUSHLRNS:
2784 case mfPUSH4NS:
2785 case mfPUSHUNS:
2786 case mfPUSHDNS:
2787 case mfPUSHLNS:
2788 case mfPUSHRNS:
2789 case mfPUSHUDINS:
2790 case mfPUSHLRINS:
2791 case mfPUSH4INS:
2792 case mfPUSHUINS:
2793 case mfPUSHDINS:
2794 case mfPUSHLINS:
2795 case mfPUSHRINS:
2796
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2797
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2798 {
2799 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2800 }
2801
2802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2803
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2804 {
2805
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2806 {
2807
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2808 {
2809 case cPUSH_HEAVY:
2810 case cPUSH_HW:
2811 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2812 72 tempitemx=x, tempitemy=y;
2813
2814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2815 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2816
2817 72 break;
2818
2819 case cPUSH_HEAVY2:
2820 case cPUSH_HW2:
2821 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2822 63 tempitemx=x, tempitemy=y;
2823
2824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2825 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2826
2827 63 break;
2828 }
2829 1032 }
2830 2438 }
2831
2832 3148 break;
2833
2834 case mfWHISTLE:
2835
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2836 {
2837 tempitem=getItemID(itemsbuf,itype_whistle,1);
2838
2839 if(tempitem<0) break;
2840
2841 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2842 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2843 {
2844 tempitemx=x;
2845 tempitemy=y;
2846 }
2847
2848 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2849 }
2850
2851 2418 break;
2852
2853 //Why is this here?
2854 case mfFAIRY:
2855 case mfMAGICFAIRY:
2856 case mfALLFAIRY:
2857 if(hints)
2858 {
2859 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2860
2861 if(tempitem < 0) break;
2862
2863 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2864 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2865 {
2866 tempitemx=x;
2867 tempitemy=y;
2868 }
2869
2870 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2871 }
2872
2873 break;
2874
2875 case mfANYFIRE:
2876
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2877 {
2878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2879 252 }
2880 else
2881 {
2882 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2883
2884
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2885
2886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2887
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2888 {
2889 189 tempitemx=x;
2890 189 tempitemy=y;
2891 189 }
2892
2893 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2894 }
2895
2896 504 break;
2897
2898 case mfSTRONGFIRE:
2899 if(!hints)
2900 {
2901 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2902 }
2903 else
2904 {
2905 tempitem=getItemID(itemsbuf,itype_candle,2);
2906
2907 if(tempitem<0) break;
2908
2909 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2910 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2911 {
2912 tempitemx=x;
2913 tempitemy=y;
2914 }
2915
2916 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2917 }
2918
2919 break;
2920
2921 case mfMAGICFIRE:
2922 if(!hints)
2923 {
2924 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2925 }
2926 else
2927 {
2928 tempitem=getItemID(itemsbuf,itype_wand,1);
2929
2930 if(tempitem<0) break;
2931
2932 tempweapon=wFire;
2933
2934 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2935 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2936 {
2937 tempitemx=x;
2938 tempitemy=y;
2939 }
2940 else
2941 {
2942 tempweaponx=x;
2943 tempweapony=y;
2944 }
2945
2946 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2947 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2948 }
2949
2950 break;
2951
2952 case mfDIVINEFIRE:
2953 if(!hints)
2954 {
2955 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2956 }
2957 else
2958 {
2959 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2960
2961 if(tempitem<0) break;
2962
2963 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2964 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2965 {
2966 tempitemx=x;
2967 tempitemy=y;
2968 }
2969
2970 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2971 }
2972
2973 break;
2974
2975 case mfARROW:
2976
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2977 {
2978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2979 732 }
2980 else
2981 {
2982 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2983
2984
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2985
2986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2987
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2988 {
2989 61 tempitemx=x;
2990 61 tempitemy=y;
2991 61 }
2992
2993 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2994 }
2995
2996 814 break;
2997
2998 case mfSARROW:
2999 if(!hints)
3000 {
3001 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3002 }
3003 else
3004 {
3005 tempitem=getItemID(itemsbuf,itype_arrow,2);
3006
3007 if(tempitem<0) break;
3008
3009 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3010 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3011 {
3012 tempitemx=x;
3013 tempitemy=y;
3014 }
3015
3016 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3017 }
3018
3019 break;
3020
3021 case mfGARROW:
3022 if(!hints)
3023 {
3024 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3025 }
3026 else
3027 {
3028 tempitem=getItemID(itemsbuf,itype_arrow,3);
3029
3030 if(tempitem<0) break;
3031
3032 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3033 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3034 {
3035 tempitemx=x;
3036 tempitemy=y;
3037 }
3038
3039 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3040 }
3041
3042 break;
3043
3044 case mfBOMB:
3045
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3046 {
3047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3048 16 }
3049 else
3050 {
3051 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3052 17 tempweapon = wLitBomb;
3053
3054 //if (tempitem<0) break;
3055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3056
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3057 {
3058 12 tempweaponx=x;
3059 12 tempweapony=y;
3060 12 }
3061
3062 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3063 }
3064
3065 33 break;
3066
3067 case mfSBOMB:
3068
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3069 {
3070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3071 48 }
3072 else
3073 {
3074 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3075 //if (tempitem<0) break;
3076 48 tempweapon = wLitSBomb;
3077
3078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3079
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3080 {
3081 36 tempweaponx=x;
3082 36 tempweapony=y;
3083 36 }
3084
3085 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3086 }
3087
3088 96 break;
3089
3090 case mfARMOS_SECRET:
3091
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3092 {
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3094 12 }
3095 24 break;
3096
3097 case mfBRANG:
3098
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3099 {
3100 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3101 }
3102 else
3103 {
3104 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3105
3106
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3107
3108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3109
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3110 {
3111 4 tempitemx=x;
3112 4 tempitemy=y;
3113 4 }
3114
3115 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3116 }
3117
3118 5 break;
3119
3120 case mfMBRANG:
3121 if(!hints)
3122 {
3123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3124 }
3125 else
3126 {
3127 tempitem=getItemID(itemsbuf,itype_brang,2);
3128
3129 if(tempitem<0) break;
3130
3131 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3132 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3133 {
3134 tempitemx=x;
3135 tempitemy=y;
3136 }
3137
3138 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3139 }
3140
3141 break;
3142
3143 case mfFBRANG:
3144 if(!hints)
3145 {
3146 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3147 }
3148 else
3149 {
3150 tempitem=getItemID(itemsbuf,itype_brang,3);
3151
3152 if(tempitem<0) break;
3153
3154 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3155 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3156 {
3157 tempitemx=x;
3158 tempitemy=y;
3159 }
3160
3161 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3162 }
3163
3164 break;
3165
3166 case mfWANDMAGIC:
3167 if(!hints)
3168 {
3169 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3170 }
3171 else
3172 {
3173 tempitem=getItemID(itemsbuf,itype_wand,1);
3174
3175 if(tempitem<0) break;
3176
3177 tempweapon=itemsbuf[tempitem].wpn3;
3178
3179 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3180 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3181 {
3182 tempitemx=x;
3183 tempitemy=y;
3184 }
3185 else
3186 {
3187 tempweaponx=x;
3188 tempweapony=y;
3189 --lens_hint_weapon[wMagic][4];
3190
3191 if(lens_hint_weapon[wMagic][4]<-8)
3192 {
3193 lens_hint_weapon[wMagic][4]=8;
3194 }
3195 }
3196
3197 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3198 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3199 }
3200
3201 break;
3202
3203 case mfREFMAGIC:
3204
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3205 {
3206 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3207 }
3208 else
3209 {
3210 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3211
3212
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3213
3214 16 tempweapon=ewMagic;
3215
3216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3217
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3218 {
3219 13 tempitemx=x;
3220 13 tempitemy=y;
3221 13 }
3222 else
3223 {
3224 3 tempweaponx=x;
3225 3 tempweapony=y;
3226
3227
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3228 {
3229 1 --lens_hint_weapon[ewMagic][4];
3230 1 }
3231 else
3232 {
3233 2 ++lens_hint_weapon[ewMagic][4];
3234 }
3235
3236
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3237 {
3238 lens_hint_weapon[ewMagic][2]=up;
3239 }
3240
3241
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3242 {
3243 2 lens_hint_weapon[ewMagic][2]=down;
3244 2 }
3245 }
3246
3247 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3248 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3249 }
3250
3251 16 break;
3252
3253 case mfREFFIREBALL:
3254
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3255 {
3256 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3257 }
3258 else
3259 {
3260 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3261
3262
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3263
3264 16 tempweapon=ewFireball;
3265
3266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3267
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3268 {
3269 12 tempitemx=x;
3270 12 tempitemy=y;
3271 12 tempweaponx=x;
3272 12 tempweapony=y;
3273 12 ++lens_hint_weapon[ewFireball][3];
3274
3275
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3276 {
3277 1 lens_hint_weapon[ewFireball][3]=-8;
3278 1 lens_hint_weapon[ewFireball][4]=8;
3279 1 }
3280
3281
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3282 {
3283 8 ++lens_hint_weapon[ewFireball][4];
3284 8 }
3285 else
3286 {
3287 4 --lens_hint_weapon[ewFireball][4];
3288 }
3289 12 }
3290
3291 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3292 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3293 }
3294
3295 16 break;
3296
3297 case mfSWORD:
3298
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3299 {
3300 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3301 }
3302 else
3303 {
3304 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3305
3306
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3307
3308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3309
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3310 {
3311 5 tempitemx=x;
3312 5 tempitemy=y;
3313 5 }
3314
3315 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3316 }
3317
3318 7 break;
3319
3320 case mfWSWORD:
3321 if(!hints)
3322 {
3323 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3324 }
3325 else
3326 {
3327 tempitem=getItemID(itemsbuf,itype_sword,2);
3328
3329 if(tempitem<0) break;
3330
3331 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3332 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3333 {
3334 tempitemx=x;
3335 tempitemy=y;
3336 }
3337
3338 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3339 }
3340
3341 break;
3342
3343 case mfMSWORD:
3344 if(!hints)
3345 {
3346 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3347 }
3348 else
3349 {
3350 tempitem=getItemID(itemsbuf,itype_sword,3);
3351
3352 if(tempitem<0) break;
3353
3354 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3355 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3356 {
3357 tempitemx=x;
3358 tempitemy=y;
3359 }
3360
3361 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3362 }
3363
3364 break;
3365
3366 case mfXSWORD:
3367 if(!hints)
3368 {
3369 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3370 }
3371 else
3372 {
3373 tempitem=getItemID(itemsbuf,itype_sword,4);
3374
3375 if(tempitem<0) break;
3376
3377 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3378 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3379 {
3380 tempitemx=x;
3381 tempitemy=y;
3382 }
3383
3384 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3385 }
3386
3387 break;
3388
3389 case mfSWORDBEAM:
3390
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3391 {
3392 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3393 }
3394 else
3395 {
3396 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3397
3398
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3399
3400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3401
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3402 {
3403 11 tempitemx=x;
3404 11 tempitemy=y;
3405 11 }
3406
3407 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3408 }
3409
3410 16 break;
3411
3412 case mfWSWORDBEAM:
3413 if(!hints)
3414 {
3415 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3416 }
3417 else
3418 {
3419 tempitem=getItemID(itemsbuf,itype_sword,2);
3420
3421 if(tempitem<0) break;
3422
3423 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3424 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3425 {
3426 tempitemx=x;
3427 tempitemy=y;
3428 }
3429
3430 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3431 }
3432
3433 break;
3434
3435 case mfMSWORDBEAM:
3436 if(!hints)
3437 {
3438 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3439 }
3440 else
3441 {
3442 tempitem=getItemID(itemsbuf,itype_sword,3);
3443
3444 if(tempitem<0) break;
3445
3446 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3447 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3448 {
3449 tempitemx=x;
3450 tempitemy=y;
3451 }
3452
3453 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3454 }
3455
3456 break;
3457
3458 case mfXSWORDBEAM:
3459 if(!hints)
3460 {
3461 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3462 }
3463 else
3464 {
3465 tempitem=getItemID(itemsbuf,itype_sword,4);
3466
3467 if(tempitem<0) break;
3468
3469 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3470 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3471 {
3472 tempitemx=x;
3473 tempitemy=y;
3474 }
3475
3476 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3477 }
3478
3479 break;
3480
3481 case mfHOOKSHOT:
3482
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3483 {
3484 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3485 }
3486 else
3487 {
3488 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3489
3490
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3491
3492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3493
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3494 {
3495 12 tempitemx=x;
3496 12 tempitemy=y;
3497 12 }
3498
3499 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3500 }
3501
3502 17 break;
3503
3504 case mfWAND:
3505
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3506 {
3507 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3508 }
3509 else
3510 {
3511 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3512
3513
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3514
3515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3516
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3517 {
3518 28 tempitemx=x;
3519 28 tempitemy=y;
3520 28 }
3521
3522 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3523 }
3524
3525 35 break;
3526
3527 case mfHAMMER:
3528
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3529 {
3530 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3531 }
3532 else
3533 {
3534 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3535
3536
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3537
3538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3539
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3540 {
3541 13 tempitemx=x;
3542 13 tempitemy=y;
3543 13 }
3544
3545 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3546 }
3547
3548 17 break;
3549
3550 case mfARMOS_ITEM:
3551 case mfDIVE_ITEM:
3552
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3553 {
3554 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3555 2064 }
3556 2064 break;
3557
3558 case 16:
3559 case 17:
3560 case 18:
3561 case 19:
3562 case 20:
3563 case 21:
3564 case 22:
3565 case 23:
3566 case 24:
3567 case 25:
3568 case 26:
3569 case 27:
3570 case 28:
3571 case 29:
3572 case 30:
3573 case 31:
3574
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3576 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3577
3578 3618 break;
3579 case mfSECRETSNEXT:
3580 if(!hints)
3581 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3582 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3583
3584 break;
3585
3586 case mfSTRIKE:
3587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3588 {
3589 906 goto special;
3590 }
3591 else
3592 {
3593 break;
3594 }
3595
3596 28640 default: goto special;
3597
3598 special:
3599
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3600 {
3601
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3602 {
3603 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3604 4913 }
3605 6549 }
3606
3607 29546 break;
3608 }
3609 5748864 }
3610 2874432 }
3611
3612
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3613 {
3614
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3615 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3616
3617
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3618 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3619
3620
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3621 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3622
3623
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3624 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3625
3626
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3627 {
3628 43 showbombeddoor(dest, 0);
3629 43 }
3630
3631
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3632 {
3633 39 showbombeddoor(dest, 1);
3634 39 }
3635
3636
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3637 {
3638 showbombeddoor(dest, 2);
3639 }
3640
3641
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3642 {
3643 37 showbombeddoor(dest, 3);
3644 37 }
3645 8166 }
3646
3647
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3648 {
3649
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3650 {
3651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3652 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3653 1123 }
3654 else
3655 {
3656
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3657 {
3658 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3659 48 int32_t tempitemx=-16;
3660 48 int32_t tempitemy=-16;
3661
3662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3663
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3664 {
3665 24 tempitemx=tmpscr->stairx;
3666 24 tempitemy=tmpscr->stairy+playing_field_offset;
3667 24 }
3668
3669 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3670 48 }
3671 }
3672 2034 }
3673 }
3674 16332 }
3675
3676 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3677
3678 7997 void draw_lens_over()
3679 {
3680 // Oh, what the heck.
3681 static BITMAP *lens_scr = NULL;
3682 static int32_t last_width = -1;
3683 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3684
3685 // Only redraw the circle if the size has changed
3686
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3687 {
3688
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3689 {
3690 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3691 5 }
3692
3693 5 clear_to_color(lens_scr, BLACK);
3694 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3695 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3696 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3697 5 last_width=width;
3698 5 }
3699
3700 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3701 7997 }
3702
3703 //----------------------------------------------------------------
3704
3705 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3706 {
3707 //recreating a big bitmap every frame is highly sluggish.
3708
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3709 30701 clear_to_color(wavebuf, BLACK);
3710 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3711
3712 int32_t ofs;
3713 // int32_t amplitude=8;
3714 // int32_t wavelength=4;
3715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3716
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3717 30701 int32_t amp2=168;
3718
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3719 30701 int32_t i=frame%amp2;
3720
3721
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3722 {
3723
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3724 {
3725 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3726 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3727 }
3728 else
3729 {
3730 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3731 }
3732
3733
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3734 {
3735
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3736 {
3737 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3738 1320388608 }
3739 5157768 }
3740 5157768 }
3741 30701 }
3742
3743 3360 void draw_fuzzy(int32_t fuzz)
3744 // draws from right half of scrollbuf to framebuf
3745 {
3746 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3747 byte *start, *si, *di;
3748
3749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if(fuzz<1)
3750 fuzz = 1;
3751
3752 3360 xstep = 128%fuzz;
3753
3754
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 2660 times.
3360 if(xstep > 0)
3755 2660 xstep = fuzz-xstep;
3756
3757 3360 ystep = 112%fuzz;
3758
3759
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 2380 times.
3360 if(ystep > 0)
3760 2380 ystep = fuzz-ystep;
3761
3762 3360 firsty = 1;
3763
3764
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 121240 times.
124600 for(y=0; y<224;)
3765 {
3766 121240 start = &(scrollbuf->line[y][256]);
3767
3768
4/4
✓ Branch 0 taken 119560 times.
✓ Branch 1 taken 754320 times.
✓ Branch 2 taken 752640 times.
✓ Branch 3 taken 121240 times.
873880 for(dy=0; dy<ystep && dy+y<224; dy++)
3769 {
3770 752640 si = start;
3771 752640 di = &(framebuf->line[y+dy][0]);
3772 752640 i = xstep;
3773 752640 firstx = 1;
3774
3775
2/2
✓ Branch 0 taken 192675840 times.
✓ Branch 1 taken 752640 times.
193428480 for(dx=0; dx<256; dx++)
3776 {
3777 192675840 *(di++) = *si;
3778
3779
2/2
✓ Branch 0 taken 162350720 times.
✓ Branch 1 taken 30325120 times.
192675840 if(++i >= fuzz)
3780 {
3781
2/2
✓ Branch 0 taken 29572480 times.
✓ Branch 1 taken 752640 times.
30325120 if(!firstx)
3782 29572480 si += fuzz;
3783 else
3784 {
3785 752640 si += fuzz-xstep;
3786 752640 firstx = 0;
3787 }
3788
3789 30325120 i = 0;
3790 30325120 }
3791 192675840 }
3792 752640 }
3793
3794
2/2
✓ Branch 0 taken 117880 times.
✓ Branch 1 taken 3360 times.
121240 if(!firsty)
3795 117880 y += fuzz;
3796 else
3797 {
3798 3360 y += ystep;
3799 3360 ystep = fuzz;
3800 3360 firsty = 0;
3801 }
3802 }
3803 3360 }
3804
3805 8132353 void updatescr(bool allowwavy)
3806 {
3807
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 8132320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
8132353 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3808
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 8132320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
8132353 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3809
3810
2/2
✓ Branch 0 taken 8106649 times.
✓ Branch 1 taken 25704 times.
8132353 if(toogam)
3811 {
3812 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3813 25704 }
3814
3815
1/2
✓ Branch 0 taken 8132353 times.
✗ Branch 1 not taken.
8132353 if(Showpal)
3816 dump_pal(framebuf);
3817
3818
2/2
✓ Branch 0 taken 7954422 times.
✓ Branch 1 taken 177931 times.
8132353 if(!Playing)
3819 177931 black_opening_count=0;
3820
3821
2/2
✓ Branch 0 taken 8078101 times.
✓ Branch 1 taken 54252 times.
8132353 if(black_opening_count<0) //shape is opening up
3822 {
3823 54252 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3824
3825
2/4
✓ Branch 0 taken 54252 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54252 times.
54252 if(Advance||(!Paused))
3826 {
3827 54252 ++black_opening_count;
3828 54252 }
3829 54252 }
3830
2/2
✓ Branch 0 taken 8057509 times.
✓ Branch 1 taken 20592 times.
8078101 else if(black_opening_count>0) //shape is closing
3831 {
3832 20592 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3833
3834
2/4
✓ Branch 0 taken 20592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20592 times.
20592 if(Advance||(!Paused))
3835 {
3836 20592 --black_opening_count;
3837 20592 }
3838 20592 }
3839
3840
3/4
✓ Branch 0 taken 8058643 times.
✓ Branch 1 taken 73710 times.
✓ Branch 2 taken 8058643 times.
✗ Branch 3 not taken.
8132353 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3841 {
3842 black_opening_shape = bosCIRCLE;
3843 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3844 refreshTints();
3845 refreshpal=true;
3846 }
3847
3848
2/2
✓ Branch 0 taken 7887462 times.
✓ Branch 1 taken 244891 times.
8132353 if(refreshpal)
3849 {
3850 244891 refreshpal=false;
3851 244891 RAMpal[253] = _RGB(0,0,0);
3852 244891 RAMpal[254] = _RGB(63,63,63);
3853 244891 hw_palette = &RAMpal;
3854 244891 update_hw_pal = true;
3855
3856 244891 create_rgb_table(&rgb_table, RAMpal, NULL);
3857 244891 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3858 244891 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3859
3860
2/2
✓ Branch 0 taken 62692096 times.
✓ Branch 1 taken 244891 times.
62936987 for(int32_t q=0; q<PAL_SIZE; q++)
3861 {
3862 62692096 trans_table2.data[0][q] = q;
3863 62692096 trans_table2.data[q][q] = q;
3864 62692096 }
3865 244891 }
3866
3867 8132353 bool clearwavy = (wavy <= 0);
3868
3869
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 8125108 times.
8132353 if(wavy <= 0)
3870 {
3871 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3872 8125108 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3873 8125108 }
3874
3875 8132353 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3876
3877
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 8101402 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
8132353 if(wavy && Playing && allowwavy)
3878 {
3879 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3880 30701 }
3881
3882
2/2
✓ Branch 0 taken 8125108 times.
✓ Branch 1 taken 7245 times.
8132353 if(clearwavy)
3883 8125108 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3884
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3885 7245 wavy--; // Wavy was set by a script. Decrement it.
3886
3887
5/6
✓ Branch 0 taken 7954422 times.
✓ Branch 1 taken 177931 times.
✓ Branch 2 taken 184496 times.
✓ Branch 3 taken 7769926 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 184496 times.
8132353 if(Playing && msgpos && !screenscrolling)
3888 {
3889
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_bg_display_buf->clip))
3890 184496 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3891
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_portrait_display_buf->clip))
3892 184496 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3893
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_txt_display_buf->clip))
3894 184496 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3895 184496 }
3896
3897 /*
3898 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3899 {
3900 BITMAP* subBmp = 0;
3901 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3902 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3903 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3904 destroy_bitmap(subBmp);
3905 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3906 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3907 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3908 }
3909 */
3910
3911
2/2
✓ Branch 0 taken 8094836 times.
✓ Branch 1 taken 37517 times.
8132353 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3912
3913
2/2
✓ Branch 0 taken 8099461 times.
✓ Branch 1 taken 32892 times.
8132353 if(nosubscr)
3914 {
3915 32892 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3916 32892 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3917 32892 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3918 32892 }
3919
3920 //TODO: Optimize blit 'overcalls' -Gleeok
3921
2/2
✓ Branch 0 taken 32892 times.
✓ Branch 1 taken 8099461 times.
8132353 BITMAP *source = nosubscr ? panorama : wavybuf;
3922 8132353 blit(source,framebuf,0,0,0,0,256,224);
3923
3924 8132353 update_hw_screen();
3925 8132353 }
3926
3927 //----------------------------------------------------------------
3928
3929 PALETTE sys_pal;
3930
3931 int32_t onGUISnapshot()
3932 {
3933 char buf[200];
3934 int32_t num=0;
3935 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3936 do
3937 {
3938 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3939 }
3940 while(num<99999 && exists(buf));
3941
3942 BITMAP *b = create_bitmap_ex(8,resx,resy);
3943
3944 if(b)
3945 {
3946 if(MenuOpen)
3947 {
3948 //Cannot load game's palette while GUI elements are in focus. -Z
3949 //If there is a way to do this, then I have missed it.
3950 /*
3951 game_pal();
3952 RAMpal[253] = _RGB(0,0,0);
3953 RAMpal[254] = _RGB(63,63,63);
3954 zc_set_palette_range(RAMpal,0,255,false);
3955 memcpy(RAMpal, snappal, sizeof(snappal));
3956 create_rgb_table(&rgb_table, RAMpal, NULL);
3957 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3958 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3959
3960 for(int32_t q=0; q<PAL_SIZE; q++)
3961 {
3962 trans_table2.data[0][q] = q;
3963 trans_table2.data[q][q] = q;
3964 }
3965 */
3966 //ringcolor(false);
3967 //get_palette(RAMpal);
3968 blit(screen,b,0,0,0,0,resx,resy);
3969 //al_trace("Menu Open\n");
3970 //game_pal();
3971 //PALETTE temppal;
3972 //get_palette(temppal);
3973 //system_pal();
3974 save_bitmap(buf,b,sys_pal);
3975 //save_bitmap(buf,b,RAMpal);
3976 //save_bitmap(buf,b,snappal);
3977 }
3978 else
3979 {
3980 blit(screen,b,0,0,0,0,resx,resy);
3981 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3982 }
3983 destroy_bitmap(b);
3984 }
3985
3986 return D_O_K;
3987 }
3988
3989 int32_t onNonGUISnapshot()
3990 {
3991 PALETTE temppal;
3992 get_palette(temppal);
3993 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3994
3995 char buf[200];
3996 int32_t num=0;
3997
3998 do
3999 {
4000 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4001 }
4002 while(num<99999 && exists(buf));
4003
4004 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
4005
4006 return D_O_K;
4007 }
4008
4009 int32_t onSnapshot()
4010 {
4011 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4012 {
4013 onGUISnapshot();
4014 }
4015 else
4016 {
4017 onNonGUISnapshot();
4018 }
4019
4020 return D_O_K;
4021 }
4022
4023 int32_t onSaveMapPic()
4024 {
4025 int32_t mapres2 = 0;
4026 char buf[200];
4027 int32_t num=0;
4028 mapscr tmpscr_b[2];
4029 mapscr tmpscr_c[6];
4030 BITMAP* _screen_draw_buffer = NULL;
4031 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4032 set_clip_state(_screen_draw_buffer,1);
4033
4034 for(int32_t i=0; i<6; ++i)
4035 {
4036 tmpscr_c[i] = tmpscr2[i];
4037 tmpscr2[i].zero_memory();
4038
4039 if(i>=2)
4040 {
4041 continue;
4042 }
4043
4044 tmpscr_b[i] = tmpscr[i];
4045 tmpscr[i].zero_memory();
4046 }
4047
4048 do
4049 {
4050 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4051 }
4052 while(num<99999 && exists(buf));
4053
4054 BITMAP* mappic = NULL;
4055
4056
4057 bool done=false, redraw=true;
4058
4059 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4060
4061 if(!mappic)
4062 {
4063 system_pal();
4064 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4065 game_pal();
4066 return D_O_K;;
4067 }
4068
4069 // draw the map
4070 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4071
4072 for(int32_t y=0; y<8; y++)
4073 {
4074 for(int32_t x=0; x<16; x++)
4075 {
4076 if(!displayOnMap(x, y))
4077 {
4078 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4079 }
4080 else
4081 {
4082 int32_t s = (y<<4) + x;
4083 loadscr2(1,s,-1);
4084
4085 for(int32_t i=0; i<6; i++)
4086 {
4087 if(tmpscr[1].layermap[i]<=0)
4088 continue;
4089
4090 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4091 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4092 {
4093 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4094
4095 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4096 }
4097 }
4098
4099 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4100
4101 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4102
4103 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4104 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4105
4106 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4107
4108 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4109 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4110 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4111 {
4112 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4113 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4114 }
4115 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4116
4117 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4118
4119 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4120 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4121 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4122 {
4123 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4124 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4125 }
4126 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4127 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4128
4129 }
4130
4131 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4132 }
4133 }
4134
4135 for(int32_t i=0; i<6; ++i)
4136 {
4137 tmpscr2[i]=tmpscr_c[i];
4138
4139 if(i>=2)
4140 {
4141 continue;
4142 }
4143
4144 tmpscr[i]=tmpscr_b[i];
4145 }
4146
4147 save_bitmap(buf,mappic,RAMpal);
4148 destroy_bitmap(mappic);
4149 destroy_bitmap(_screen_draw_buffer);
4150 return D_O_K;
4151 }
4152
4153 /*
4154 int32_t onSaveMapPic()
4155 {
4156 BITMAP* mappic = NULL;
4157 BITMAP* _screen_draw_buffer = NULL;
4158 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4159 int32_t mapres2 = 0;
4160 char buf[20];
4161 int32_t num=0;
4162 set_clip_state(_screen_draw_buffer,1);
4163 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4164
4165 do
4166 {
4167 sprintf(buf, "zelda%03d.png", ++num);
4168 }
4169 while(num<999 && exists(buf));
4170
4171 // if(!mappic) {
4172 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4173
4174 if(!mappic)
4175 {
4176 system_pal();
4177 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4178 game_pal();
4179 return D_O_K;
4180 }
4181
4182 // }
4183
4184 int32_t layermap, layerscreen;
4185 int32_t x2=0;
4186
4187 // draw the map
4188 for(int32_t y=0; y<8; y++)
4189 {
4190 for(int32_t x=0; x<16; x++)
4191 {
4192 int32_t s = (y<<4) + x;
4193
4194 if(!displayOnMap(x, y))
4195 {
4196 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4197 }
4198 else
4199 {
4200 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4201 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4202
4203 for(int32_t k=0; k<4; k++)
4204 {
4205 if(k==2)
4206 {
4207 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4208 }
4209
4210 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4211
4212 if(layermap>-1)
4213 {
4214 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4215
4216 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4217 {
4218 for(int32_t i=0; i<176; i++)
4219 {
4220 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4221 }
4222 }
4223 else
4224 {
4225 for(int32_t i=0; i<176; i++)
4226 {
4227 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4228 }
4229 }
4230 }
4231 }
4232
4233 for(int32_t i=0; i<176; i++)
4234 {
4235 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4236 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4237 {
4238 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4239 }
4240 }
4241
4242 for(int32_t k=4; k<6; k++)
4243 {
4244 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4245
4246 if(layermap>-1)
4247 {
4248 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4249
4250 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4251 {
4252 for(int32_t i=0; i<176; i++)
4253 {
4254 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4255 }
4256 }
4257 else
4258 {
4259 for(int32_t i=0; i<176; i++)
4260 {
4261 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4262 }
4263 }
4264 }
4265 }
4266 }
4267
4268 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4269 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4270 }
4271
4272 }
4273
4274 save_bitmap(buf,mappic,RAMpal);
4275 destroy_bitmap(mappic);
4276 destroy_bitmap(_screen_draw_buffer);
4277 return D_O_K;
4278 }
4279 */
4280
4281 14 void f_Quit(int32_t type)
4282 {
4283
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4284 return;
4285
4286 14 bool from_menu = is_sys_pal;
4287
4288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4289 {
4290 14 music_pause();
4291 14 pause_all_sfx();
4292 14 sys_mouse();
4293 14 }
4294 14 enter_sys_pal();
4295 14 clear_keybuf();
4296
4297
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 13 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4298 13 replay_poll();
4299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4300 14 replay_peek_quit();
4301
4302
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4303 switch(type)
4304 {
4305 case qQUIT:
4306 onQuit();
4307 break;
4308
4309 case qRESET:
4310 onReset();
4311 break;
4312
4313 case qEXIT:
4314 onExit();
4315 break;
4316 }
4317
4318
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4319 {
4320 14 kill_sfx();
4321 14 music_stop();
4322 14 exit_sys_pal();
4323 14 update_hw_screen();
4324 14 }
4325 else
4326 {
4327 exit_sys_pal();
4328 if(!from_menu)
4329 {
4330 music_resume();
4331 resume_all_sfx();
4332 }
4333 }
4334
4335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4336 14 game_mouse();
4337 14 eat_buttons();
4338
4339 14 zc_readrawkey(KEY_ESC);
4340
4341 14 zc_readrawkey(KEY_ENTER);
4342 14 }
4343
4344 //----------------------------------------------------------------
4345
4346 int32_t onNoWalls()
4347 {
4348 cheats_enqueue(Cheat::Walls);
4349 return D_O_K;
4350 }
4351
4352 int32_t onIgnoreSideview()
4353 {
4354 cheats_enqueue(Cheat::IgnoreSideView);
4355 return D_O_K;
4356 }
4357
4358 8132269 int32_t input_idle(bool checkmouse)
4359 {
4360 static int32_t mx, my, mz, mb;
4361
4362
4/6
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2136415 times.
✓ Branch 3 taken 5995854 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2136415 times.
10268684 if(keypressed() || zc_key_pressed() ||
4363
4/8
✓ Branch 0 taken 2136415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2136415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2136415 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2136415 times.
✗ Branch 7 not taken.
2136415 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4364 {
4365 5995854 idle_count = 0;
4366
4367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5995854 times.
5995854 if(active_count < MAX_ACTIVE)
4368 {
4369 5995854 ++active_count;
4370 5995854 }
4371 5995854 }
4372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2136415 times.
2136415 else if(idle_count < MAX_IDLE)
4373 {
4374 2136415 ++idle_count;
4375 2136415 active_count = 0;
4376 2136415 }
4377
4378 8132269 mx = mouse_x;
4379 8132269 my = mouse_y;
4380 8132269 mz = mouse_z;
4381 8132269 mb = mouse_b;
4382
4383 8132269 return idle_count;
4384 }
4385
4386 int32_t onGoFast()
4387 {
4388 cheats_enqueue(Cheat::Fast);
4389 return D_O_K;
4390 }
4391
4392 int32_t onKillCheat()
4393 {
4394 cheats_enqueue(Cheat::Kill);
4395 return D_O_K;
4396 }
4397
4398 int32_t onSecretsCheat()
4399 {
4400 cheats_enqueue(Cheat::TrigSecrets);
4401 return D_O_K;
4402 }
4403 int32_t onSecretsCheatPerm()
4404 {
4405 cheats_enqueue(Cheat::TrigSecretsPerm);
4406 return D_O_K;
4407 }
4408
4409 int32_t onShowLayer0()
4410 {
4411 show_layer_0 = !show_layer_0;
4412 return D_O_K;
4413 }
4414 int32_t onShowLayer1()
4415 {
4416 show_layer_1 = !show_layer_1;
4417 return D_O_K;
4418 }
4419 int32_t onShowLayer2()
4420 {
4421 show_layer_2 = !show_layer_2;
4422 return D_O_K;
4423 }
4424 int32_t onShowLayer3()
4425 {
4426 show_layer_3 = !show_layer_3;
4427 return D_O_K;
4428 }
4429 int32_t onShowLayer4()
4430 {
4431 show_layer_4 = !show_layer_4;
4432 return D_O_K;
4433 }
4434 int32_t onShowLayer5()
4435 {
4436 show_layer_5 = !show_layer_5;
4437 return D_O_K;
4438 }
4439 int32_t onShowLayer6()
4440 {
4441 show_layer_6 = !show_layer_6;
4442 return D_O_K;
4443 }
4444 int32_t onShowLayerO()
4445 {
4446 show_layer_over=!show_layer_over;
4447 return D_O_K;
4448 }
4449 int32_t onShowLayerP()
4450 {
4451 show_layer_push=!show_layer_push;
4452 return D_O_K;
4453 }
4454 int32_t onShowLayerS()
4455 {
4456 show_sprites=!show_sprites;
4457 return D_O_K;
4458 }
4459 int32_t onShowLayerF()
4460 {
4461 show_ffcs=!show_ffcs;
4462 return D_O_K;
4463 }
4464 int32_t onShowLayerW()
4465 {
4466 show_walkflags=!show_walkflags;
4467 if(show_walkflags)
4468 show_effectflags = false;
4469 return D_O_K;
4470 }
4471 int32_t onShowLayerE()
4472 {
4473 show_effectflags=!show_effectflags;
4474 if(show_effectflags)
4475 show_walkflags = false;
4476 return D_O_K;
4477 }
4478 int32_t onShowFFScripts()
4479 {
4480 show_ff_scripts=!show_ff_scripts;
4481 return D_O_K;
4482 }
4483 int32_t onShowHitboxes()
4484 {
4485 show_hitboxes=!show_hitboxes;
4486 return D_O_K;
4487 }
4488 int32_t onShowInfoOpacity()
4489 {
4490 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4491 zc_set_config("zc","debug_info_opacity",info_opacity);
4492 return D_O_K;
4493 }
4494
4495 int32_t onLightSwitch()
4496 {
4497 cheats_enqueue(Cheat::Light);
4498 return D_O_K;
4499 }
4500
4501 int32_t onGoTo();
4502 int32_t onGoToComplete();
4503
4504 8132269 void syskeys()
4505 {
4506 8132269 update_system_keys();
4507
4508 int32_t oldtitle_version;
4509
4510
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(close_button_quit)
4511 {
4512 close_button_quit=false;
4513 f_Quit(qEXIT);
4514 }
4515
4516 8132269 poll_joystick();
4517
4518
2/10
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8132269 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8132269 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4519 {
4520 oldtitle_version=title_version;
4521 System();
4522 }
4523
4524 8132269 mouse_down=gui_mouse_b();
4525
4526
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F1))
4527 {
4528 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4529 {
4530 halt=!halt;
4531 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4532 }
4533 else
4534 {
4535 Throttlefps=!Throttlefps;
4536 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4537 logic_counter=0;
4538 }
4539 }
4540
4541 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4542 /*
4543 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4544 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4545 */
4546
4547
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F2))
4548 {
4549 ShowFPS=!ShowFPS;
4550 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4551 }
4552
4553
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8132269 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4554
4555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8132269 if(zc_read_system_key(KEY_F4) && Playing)
4556 {
4557 Paused=true;
4558 Advance=true;
4559 }
4560
4561
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F6)) onTryQuit();
4562
4563 #ifndef ALLEGRO_MACOSX
4564
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4565
4566
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4567 #else
4568 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4569
4570 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4571 #endif
4572
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8132269 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4573
4574
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if (zc_read_system_key(KEY_F12))
4575 {
4576 onSnapshot();
4577 }
4578
4579
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8132269 if(debug_enabled && zc_read_system_key(KEY_TAB))
4580 set_debug(!get_debug());
4581
4582
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(CheatModifierKeys())
4583 {
4584 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4585 {
4586 if(!bindable_cheat(c))
4587 continue;
4588 if(get_debug() || cheat >= cheat_lvl(c))
4589 {
4590 if(checkcheat(c))
4591 cheats_hit_bind(c);
4592 }
4593 }
4594 }
4595
4596
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(volkeys)
4597 {
4598 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4599
4600 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4601
4602 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4603
4604 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4605 }
4606
4607
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8132269 if(!get_debug() || !SystemKeys || replay_is_replaying())
4608 8132269 goto bottom;
4609
4610 if(zc_readkey(KEY_D))
4611 {
4612 details = !details;
4613 rectfill(screen,0,0,319,7,BLACK);
4614 rectfill(screen,0,8,31,239,BLACK);
4615 rectfill(screen,288,8,319,239,BLACK);
4616 rectfill(screen,32,232,287,239,BLACK);
4617 }
4618
4619 if(zc_readkey(KEY_P)) Paused=!Paused;
4620
4621 //if(zc_readkey(KEY_P)) centerHero();
4622 if(zc_readkey(KEY_A))
4623 {
4624 Paused=true;
4625 Advance=true;
4626 }
4627
4628 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4629 #ifndef ALLEGRO_MACOSX
4630 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4631
4632 if(zc_readkey(KEY_F7))
4633 {
4634 Matrix(ss_speed, ss_density, 0);
4635 game_pal();
4636 }
4637 #else
4638 // The reason these are different on Mac in the first place is that
4639 // the OS doesn't let us use F9 and F10...
4640 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4641
4642 if(zc_readkey(KEY_F9))
4643 {
4644 Matrix(ss_speed, ss_density, 0);
4645 game_pal();
4646 }
4647 #endif
4648 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4649 {
4650 //change containers
4651 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4652 {
4653 //magic containers
4654 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4655 {
4656 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4657 }
4658 else
4659 {
4660 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4661 }
4662 }
4663 else
4664 {
4665 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4666 {
4667 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4668 }
4669 else
4670 {
4671 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4672 }
4673 }
4674 }
4675
4676 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4677 {
4678 //change containers
4679 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4680 {
4681 //magic containers
4682 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4683 {
4684 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4685 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4686 //heart containers
4687 }
4688 else
4689 {
4690 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4691 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4692 }
4693 }
4694 else
4695 {
4696 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4697 {
4698 game->set_magic(zc_max(game->get_magic()-1,0));
4699 }
4700 else
4701 {
4702 game->set_life(zc_max(game->get_life()-1,0));
4703 }
4704 }
4705 }
4706
4707 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4708
4709 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4710
4711 verifyBothWeapons();
4712
4713 bottom:
4714
4715
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(input_idle(true) > after_time())
4716 {
4717 Matrix(ss_speed, ss_density, 0);
4718 game_pal();
4719 }
4720 8132269 }
4721
4722 429041 void checkQuitKeys()
4723 {
4724 #ifndef ALLEGRO_MACOSX
4725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429041 times.
429041 if(key[KEY_F9]) f_Quit(qRESET);
4726
4727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429041 times.
429041 if(key[KEY_F10]) f_Quit(qEXIT);
4728 #else
4729 if(key[KEY_F7]) f_Quit(qRESET);
4730
4731 if(key[KEY_F8]) f_Quit(qEXIT);
4732 #endif
4733 429041 }
4734
4735 8132269 bool CheatModifierKeys()
4736 {
4737 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4738 // to trigger cheats.
4739
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if (replay_is_replaying())
4740 8132269 return false;
4741
4742 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4743 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4744 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4745 {
4746 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4747 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4748 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4749 {
4750 return true;
4751 }
4752 }
4753 return false;
4754 8132269 }
4755
4756 //99:05:54, for some reason?
4757 #define OLDMAXTIME 21405240
4758 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4759 #define MAXTIME 1944000000
4760
4761 8132353 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4762 {
4763
2/2
✓ Branch 0 taken 7842198 times.
✓ Branch 1 taken 290155 times.
8132353 if(zcmusic!=NULL)
4764 {
4765 290155 zcmusic_poll();
4766 290155 }
4767
4768 8132353 updatescr(allowwavy);
4769
4770 8132353 Advance=false;
4771
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8132353 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8132353 times.
8132353 while(Paused && !Advance && !Quit)
4772 {
4773 // have to call this, otherwise we'll get an infinite loop
4774 syskeys();
4775 if(allowF6Script)
4776 {
4777 FFCore.runF6Engine();
4778 }
4779 throttleFPS();
4780
4781 #ifdef _WIN32
4782
4783 if(use_dwm_flush)
4784 {
4785 do_DwmFlush();
4786 }
4787
4788 #endif
4789
4790 // to keep music playing
4791 if(zcmusic!=NULL)
4792 {
4793 zcmusic_poll();
4794 }
4795
4796 update_hw_screen();
4797 }
4798
4799
2/2
✓ Branch 0 taken 8132281 times.
✓ Branch 1 taken 72 times.
8132353 if(Quit)
4800 72 return;
4801
4802
3/4
✓ Branch 0 taken 7954413 times.
✓ Branch 1 taken 177868 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7954413 times.
8132281 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4803 7954413 game->change_time(1);
4804
4805
3/4
✓ Branch 0 taken 8132281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1528134 times.
✓ Branch 3 taken 6604147 times.
8132281 if (!replay_is_active() || replay_get_version() >= 11)
4806
2/2
✓ Branch 0 taken 27506412 times.
✓ Branch 1 taken 1528134 times.
29034546 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4807 29034546 down_control_states[i] = raw_control_state[i];
4808
4809
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8132289 times.
8132281 if (replay_is_active())
4810 {
4811
2/2
✓ Branch 0 taken 1270471 times.
✓ Branch 1 taken 6861818 times.
8132289 if (replay_get_version() >= 3)
4812 6861818 replay_poll();
4813
4814
6/6
✓ Branch 0 taken 6604137 times.
✓ Branch 1 taken 1528132 times.
✓ Branch 2 taken 3183485 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 3082950 times.
8132289 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4815 1628667 replay_peek_input();
4816 8132269 }
4817
4818 8132281 load_control_called_this_frame = false;
4819
4820 8132281 poll_keyboard();
4821 8132281 update_keys();
4822
4823 8132281 ++frame;
4824
4825
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8132269 times.
8132281 if (replay_is_replaying())
4826 8132269 replay_do_cheats();
4827 8132281 syskeys();
4828
4829 // The mouse variables can change from the mouse thread at anytime during a frame,
4830 // so save the result at the start so that replaying is consistent.
4831 8132281 script_mouse_x = gui_mouse_x();
4832 8132281 script_mouse_y = gui_mouse_y();
4833 8132281 script_mouse_z = mouse_z;
4834 8132281 script_mouse_b = mouse_b;
4835
4836 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4837 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4838 // approach here means it doesn't matter which call adds the cheat.
4839 8132281 cheats_execute_queued();
4840
4841
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8132269 times.
8132281 if (replay_is_replaying())
4842 8132269 replay_peek_quit();
4843
2/2
✓ Branch 0 taken 8132267 times.
✓ Branch 1 taken 14 times.
8132281 if (GameFlags & GAMEFLAG_TRYQUIT)
4844 14 replay_step_quit(0);
4845
2/2
✓ Branch 0 taken 2567 times.
✓ Branch 1 taken 8129714 times.
8132281 if(allowF6Script)
4846 8129714 FFCore.runF6Engine();
4847
2/2
✓ Branch 0 taken 8132057 times.
✓ Branch 1 taken 224 times.
8132281 if (Quit)
4848 224 replay_step_quit(Quit);
4849 // Someday... maybe install a Turbo button here?
4850 8132281 throttleFPS();
4851
4852 #ifdef _WIN32
4853
4854 if(use_dwm_flush)
4855 {
4856 do_DwmFlush();
4857 }
4858
4859 #endif
4860
4861 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4862
2/2
✓ Branch 0 taken 46694 times.
✓ Branch 1 taken 8085587 times.
8132281 if(sfxcleanup)
4863 8085587 sfx_cleanup();
4864 8132353 }
4865
4866 70 void zapout()
4867 {
4868 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4869 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4870
4871 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4872 70 script_drawing_commands.Clear();
4873
4874 // zap out
4875
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=1; i<=24; i++)
4876 {
4877 1680 draw_fuzzy(i);
4878 1680 advanceframe(true);
4879
4880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4881 {
4882 break;
4883 }
4884 1680 }
4885 70 }
4886
4887 70 void zapin()
4888 {
4889 70 FFCore.warpScriptCheck();
4890 70 draw_screen(tmpscr);
4891 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4892 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4893 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4894
4895 // zap out
4896 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4897
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=24; i>=1; i--)
4898 {
4899 1680 draw_fuzzy(i);
4900 1680 advanceframe(true);
4901
4902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4903 {
4904 break;
4905 }
4906 1680 }
4907 70 }
4908
4909
4910 38 void wavyout(bool showhero)
4911 {
4912 38 draw_screen(tmpscr, showhero);
4913 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4914
4915 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4916 38 clear_to_color(wavebuf,0);
4917 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4918
4919 static PALETTE wavepal;
4920
4921 int32_t ofs;
4922 38 int32_t amplitude=8;
4923
4924 38 int32_t wavelength=4;
4925 38 double palpos=0, palstep=4, palstop=126;
4926
4927 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4928
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4929 {
4930
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4931 {
4932 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4933 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4934 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4935 408576 }
4936
4937 1596 palpos+=palstep;
4938
4939
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4940 {
4941 1596 hw_palette = &wavepal;
4942 1596 update_hw_pal = true;
4943 1596 }
4944 else
4945 {
4946 hw_palette = &RAMpal;
4947 update_hw_pal = true;
4948 }
4949
4950
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4951 {
4952
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4953 {
4954 68640768 ofs=0;
4955
4956
4/4
✓ Branch 0 taken 33503232 times.
✓ Branch 1 taken 35137536 times.
✓ Branch 2 taken 16751616 times.
✓ Branch 3 taken 16751616 times.
68640768 if((j<i)&&(j&1))
4957 {
4958 16751616 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4959 16751616 }
4960
4961 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4962 68640768 }
4963 268128 }
4964
4965 1596 advanceframe(true);
4966
4967 // animate_combos();
4968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4969 break;
4970 1596 }
4971
4972 38 destroy_bitmap(wavebuf);
4973 38 }
4974
4975 38 void wavyin()
4976 {
4977 38 draw_screen(tmpscr);
4978 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4979
4980 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4981 38 clear_to_color(wavebuf,0);
4982 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4983
4984 static PALETTE wavepal;
4985
4986 //Breaks dark rooms.
4987 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4988 /*
4989 loadfullpal();
4990 loadlvlpal(DMaps[currdmap].color);
4991 ringcolor(false);
4992 */
4993 38 refreshpal=false;
4994 int32_t ofs;
4995 38 int32_t amplitude=8;
4996 38 int32_t wavelength=4;
4997 38 double palpos=168, palstep=4, palstop=126;
4998
4999 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5000
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
5001 {
5002
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
5003 {
5004 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5005 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5006 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5007 408576 }
5008
5009 1596 palpos-=palstep;
5010
5011
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
5012 {
5013 1596 hw_palette = &wavepal;
5014 1596 update_hw_pal = true;
5015 1596 }
5016 else
5017 {
5018 hw_palette = &RAMpal;
5019 update_hw_pal = true;
5020 }
5021
5022
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
5023 {
5024
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
5025 {
5026 68640768 ofs=0;
5027
5028
4/4
✓ Branch 0 taken 34728960 times.
✓ Branch 1 taken 33911808 times.
✓ Branch 2 taken 17568768 times.
✓ Branch 3 taken 17160192 times.
68640768 if((j<(167-i))&&(j&1))
5029 {
5030 17160192 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5031 17160192 }
5032
5033 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5034 68640768 }
5035 268128 }
5036
5037 1596 advanceframe(true);
5038 // animate_combos();
5039
5040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
5041 break;
5042 1596 }
5043
5044 38 destroy_bitmap(wavebuf);
5045 38 }
5046
5047 1922 void blackscr(int32_t fcnt,bool showsubscr)
5048 {
5049 1922 reset_pal_cycling();
5050 1922 script_drawing_commands.Clear();
5051
5052 1922 FFCore.warpScriptCheck();
5053 1922 bool showtime = game->should_show_time();
5054
2/2
✓ Branch 0 taken 1922 times.
✓ Branch 1 taken 57590 times.
59512 while(fcnt>0)
5055 {
5056 57590 clear_bitmap(framebuf);
5057
5058
2/2
✓ Branch 0 taken 19740 times.
✓ Branch 1 taken 37850 times.
57590 if(showsubscr)
5059 {
5060 37850 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5061
3/4
✓ Branch 0 taken 37850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 37100 times.
37850 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5062 {
5063 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5064 750 }
5065 37850 }
5066
5067 57590 advanceframe(true);
5068
5069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57590 times.
57590 if(Quit)
5070 break;
5071
5072 57590 --fcnt;
5073 }
5074 1922 }
5075
5076 725 void openscreen(int32_t shape)
5077 {
5078 725 reset_pal_cycling();
5079 725 black_opening_count=0;
5080
5081
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
725 if(COOLSCROLL || shape>-1)
5082 {
5083 627 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5084 627 return;
5085 }
5086 else
5087 {
5088 98 Hero.setDontDraw(true);
5089 98 show_subscreen_dmap_dots=false;
5090 98 show_subscreen_numbers=false;
5091 // show_subscreen_items=false;
5092 98 show_subscreen_life=false;
5093 }
5094
5095 98 int32_t x=128;
5096
5097 98 FFCore.warpScriptCheck();
5098
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5099 {
5100 7840 draw_screen(tmpscr);
5101 //? draw_screen already draws the subscreen -DD
5102 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5103 7840 x=128-(((i*128/80)/8)*8);
5104
5105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5106 {
5107 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5108 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5109 7840 }
5110
5111 7840 advanceframe(true);
5112
5113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5114 {
5115 break;
5116 }
5117 7840 }
5118
5119 98 Hero.setDontDraw(false);
5120 98 show_subscreen_items=true;
5121 98 show_subscreen_dmap_dots=true;
5122 725 }
5123
5124 void closescreen(int32_t shape)
5125 {
5126 reset_pal_cycling();
5127 black_opening_count=0;
5128
5129 if(COOLSCROLL || shape>-1)
5130 {
5131 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5132 return;
5133 }
5134 else
5135 {
5136 Hero.setDontDraw(true);
5137 show_subscreen_dmap_dots=false;
5138 show_subscreen_numbers=false;
5139 // show_subscreen_items=false;
5140 show_subscreen_life=false;
5141 }
5142
5143 int32_t x=128;
5144
5145 FFCore.warpScriptCheck();
5146 for(int32_t i=79; i>=0; --i)
5147 {
5148 draw_screen(tmpscr);
5149 //? draw_screen already draws the subscreen -DD
5150 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5151 x=128-(((i*128/80)/8)*8);
5152
5153 if(x>0)
5154 {
5155 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5156 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5157 }
5158
5159 advanceframe(true);
5160
5161 if(Quit)
5162 {
5163 break;
5164 }
5165 }
5166
5167 Hero.setDontDraw(false);
5168 show_subscreen_items=true;
5169 show_subscreen_dmap_dots=true;
5170 }
5171
5172 179 int32_t TriforceCount()
5173 {
5174 179 int32_t c=0;
5175
5176
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5177
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5178 1044 ++c;
5179
5180 179 return c;
5181 }
5182
5183 int32_t onCustomGame()
5184 {
5185 int32_t file = getsaveslot();
5186
5187 if(file < 0)
5188 return D_O_K;
5189
5190 bool ret = (custom_game(file)!=0);
5191 return ret ? D_CLOSE : D_O_K;
5192 }
5193
5194 int32_t onContinue()
5195 {
5196 return D_CLOSE;
5197 }
5198
5199 int32_t onEsc() // Unused?? -L
5200 {
5201 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5202 }
5203
5204 int32_t onVsync()
5205 {
5206 Throttlefps = !Throttlefps;
5207 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5208 return D_O_K;
5209 }
5210
5211 int32_t onWinPosSave()
5212 {
5213 SaveWinPos = !SaveWinPos;
5214 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5215 return D_O_K;
5216 }
5217 int32_t onIntegerScaling()
5218 {
5219 scaleForceInteger = !scaleForceInteger;
5220 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5221 return D_O_K;
5222 }
5223 int32_t onStretchGame()
5224 {
5225 stretchGame = !stretchGame;
5226 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5227 return D_O_K;
5228 }
5229
5230 int32_t onClickToFreeze()
5231 {
5232 ClickToFreeze = !ClickToFreeze;
5233 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5234 return D_O_K;
5235 }
5236
5237 int32_t OnSaveZCConfig()
5238 {
5239 if(jwin_alert3(
5240 "Save Configuration",
5241 "Are you sure that you wish to save your present configuration settings?",
5242 "This will overwrite your prior settings!",
5243 NULL,
5244 "&Yes",
5245 "&No",
5246 NULL,
5247 'y',
5248 'n',
5249 0,
5250 get_zc_font(font_lfont)) == 1)
5251 {
5252 save_game_configs();
5253 return D_O_K;
5254 }
5255 else return D_O_K;
5256 }
5257
5258 int32_t OnnClearQuestDir()
5259 {
5260 if(jwin_alert3(
5261 "Clear Current Directory Cache",
5262 "Are you sure that you wish to clear the current cached directory?",
5263 "This will default the current directory to the ROOT for this instance of ZC Player!",
5264 NULL,
5265 "&Yes",
5266 "&No",
5267 NULL,
5268 'y',
5269 'n',
5270 0,
5271 get_zc_font(font_lfont)) == 1)
5272 {
5273 zc_set_config("zeldadx","win_qst_dir","");
5274 flush_config_file();
5275 strcpy(qstdir,"");
5276 #ifdef __EMSCRIPTEN__
5277 em_sync_fs();
5278 #endif
5279 return D_O_K;
5280 }
5281 else return D_O_K;
5282 }
5283
5284
5285 int32_t onConsoleZASM()
5286 {
5287 if ( !zasm_debugger )
5288 {
5289 AlertDialog("WARNING: ZASM Debugger",
5290 "Enabling this will open the ZASM Debugger Console"
5291 "\nThis will likely grind ZC to a halt with lag."
5292 "\nTo make any use of this, it is suggested that you read"
5293 "\nthe documentation for 'void Breakpoint(char[] string);'"
5294 " in 'ZScript_Additions.txt'"
5295 "\nThis is not recommended for normal users,"
5296 " and is only intended for ZC developers,"
5297 "\nor quest developers coding directly in ZASM"
5298 "\nAre you sure that you wish to open the ZASM Debugger?",
5299 [&](bool ret,bool)
5300 {
5301 if(ret)
5302 {
5303 FFCore.ZASMPrint(true);
5304 }
5305 }).show();
5306 return D_O_K;
5307 }
5308 else
5309 {
5310 FFCore.ZASMPrint(false);
5311 return D_O_K;
5312 }
5313 }
5314
5315
5316 int32_t onConsoleZScript()
5317 {
5318 if ( !zscript_debugger )
5319 {
5320 AlertDialog("ZScript Debugger",
5321 "Enabling this will open the ZScript Debugger Console"
5322 "\nThis will display any messages logged by scripts,"
5323 " including script errors."
5324 "\nAre you sure that you wish to open the ZScript Debugger?",
5325 [&](bool ret,bool)
5326 {
5327 if(ret)
5328 {
5329 FFCore.ZScriptConsole(true);
5330 }
5331 }).show();
5332 return D_O_K;
5333 }
5334 else
5335 {
5336 FFCore.ZScriptConsole(false);
5337 return D_O_K;
5338 }
5339 }
5340
5341 int32_t onClrConsoleOnReload()
5342 {
5343 clearConsoleOnReload = !clearConsoleOnReload;
5344 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5345 return D_O_K;
5346 }
5347 int32_t onClrConsoleOnLoad()
5348 {
5349 clearConsoleOnLoad = !clearConsoleOnLoad;
5350 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5351 return D_O_K;
5352 }
5353
5354
5355 int32_t onFrameSkip()
5356 {
5357 FrameSkip = !FrameSkip;
5358 return D_O_K;
5359 }
5360
5361 int32_t onSaveDragResize()
5362 {
5363 SaveDragResize = !SaveDragResize;
5364 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5365 return D_O_K;
5366 }
5367
5368 int32_t onDragAspect()
5369 {
5370 DragAspect = !DragAspect;
5371 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5372 return D_O_K;
5373 }
5374
5375 int32_t onTransLayers()
5376 {
5377 TransLayers = !TransLayers;
5378 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5379 return D_O_K;
5380 }
5381
5382 int32_t onNESquit()
5383 {
5384 NESquit = !NESquit;
5385 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5386 return D_O_K;
5387 }
5388
5389 int32_t onVolKeys()
5390 {
5391 volkeys = !volkeys;
5392 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5393 return D_O_K;
5394 }
5395
5396 int32_t onShowFPS()
5397 {
5398 ShowFPS = !ShowFPS;
5399 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5400 return D_O_K;
5401 }
5402
5403 959607742 bool is_Fkey(int32_t k)
5404 {
5405
2/2
✓ Branch 0 taken 97587228 times.
✓ Branch 1 taken 862020514 times.
959607742 switch(k)
5406 {
5407 case KEY_F1:
5408 case KEY_F2:
5409 case KEY_F3:
5410 case KEY_F4:
5411 case KEY_F5:
5412 case KEY_F6:
5413 case KEY_F7:
5414 case KEY_F8:
5415 case KEY_F9:
5416 case KEY_F10:
5417 case KEY_F11:
5418 case KEY_F12:
5419 97587228 return true;
5420 }
5421
5422 862020514 return false;
5423 959607742 }
5424
5425 void kb_getkey(DIALOG *d);
5426
5427 //Used by all keyboard key settings dialogues.
5428 void kb_clearjoystick(DIALOG *d)
5429 {
5430 d->flags|=D_SELECTED;
5431
5432 jwin_button_proc(MSG_DRAW,d,0);
5433 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5434 // text_mode(vc(11));
5435 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5436 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5437
5438 update_hw_screen(true);
5439
5440 clear_keybuf();
5441 int32_t k = next_press_key();
5442 clear_keybuf();
5443
5444 //shnarf
5445 //47=f1
5446 //59=esc
5447 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5448 // *((int32_t*)d->dp3) = k;
5449 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5450
5451
5452 d->flags&=~D_SELECTED;
5453 }
5454
5455 //Clears key to 0.
5456 //Used by all keyboard key settings dialogues.
5457 void kb_clearkey(DIALOG *d);
5458
5459 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5460 {
5461 switch(msg)
5462 {
5463 case MSG_KEY:
5464 case MSG_CLICK:
5465
5466 kb_clearjoystick(d);
5467
5468 while(gui_mouse_b())
5469 {
5470 clear_keybuf();
5471 rest(1);
5472 }
5473
5474 return D_REDRAW;
5475 }
5476
5477 return jwin_button_proc(msg,d,c);
5478 }
5479
5480 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5481 //Only used in keyboard settings dialogues to clear keys.
5482 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5483
5484 void j_getbtn(DIALOG *d)
5485 {
5486 d->flags|=D_SELECTED;
5487 jwin_button_proc(MSG_DRAW,d,0);
5488 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5489 // text_mode(vc(11));
5490 int32_t y = gui_bmp->h/2 - 12;
5491 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5492 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5493 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5494
5495 update_hw_screen(true);
5496
5497 int32_t b = next_press_btn();
5498
5499 if(b>=0)
5500 *((int32_t*)d->dp3) = b;
5501
5502 d->flags&=~D_SELECTED;
5503
5504 if (player)
5505 player->joy_on = TRUE;
5506 }
5507
5508 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5509 {
5510 switch(msg)
5511 {
5512 case MSG_KEY:
5513 case MSG_CLICK:
5514
5515 j_getbtn(d);
5516
5517 while(gui_mouse_b()) {
5518 rest(1);
5519 clear_keybuf();
5520 }
5521
5522 return D_REDRAW;
5523 }
5524
5525 return jwin_button_proc(msg,d,c);
5526 }
5527
5528 //shnarf
5529 extern const char *key_str[];
5530 std::string get_keystr(int key);
5531
5532 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5533 //extern int32_t zcmusic_bufsz;
5534
5535 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5536 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5537
5538 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5539 {
5540 //these are here to bypass compiler warnings about unused arguments
5541 c=c;
5542
5543 if(msg==MSG_DRAW)
5544 {
5545 switch(d->w)
5546 {
5547 case 0:
5548 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5549 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5550 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5551 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5552 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5553 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5554 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5555 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5556 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5557 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5558 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5559 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5560 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5561 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5562 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5563 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5564 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5565 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5566 break;
5567
5568 case 1:
5569 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5570 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5571 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5572 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5573 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5574 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5575 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5576 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5577 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5578 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5579 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5580 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5581 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5582 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5583 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5584 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5585 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5586 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5587 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5588 break;
5589
5590 case 2:
5591 sprintf(str_a," %3d",midi_volume);
5592 sprintf(str_b," %3d",digi_volume);
5593 sprintf(str_l," %3d",emusic_volume);
5594 sprintf(str_m," %3dKB",zcmusic_bufsz);
5595 sprintf(str_r," %3d",sfx_volume);
5596 strcpy(str_s,pan_str[pan_style]);
5597 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5598 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5599 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5600 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5601 break;
5602 }
5603 }
5604
5605 return D_O_K;
5606 }
5607
5608 int32_t set_vol(void *dp3, int32_t d2)
5609 {
5610 switch(((int32_t*)dp3)[0])
5611 {
5612 case 0:
5613 midi_volume = zc_min(d2<<3,255);
5614 break;
5615
5616 case 1:
5617 digi_volume = zc_min(d2<<3,255);
5618 break;
5619
5620 case 2:
5621 emusic_volume = zc_min(d2<<3,255);
5622 break;
5623
5624 case 3:
5625 sfx_volume = zc_min(d2<<3,255);
5626 break;
5627 }
5628
5629 // text_mode(vc(11));
5630 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5631 return D_O_K;
5632 }
5633
5634 int32_t set_pan(void *dp3, int32_t d2)
5635 {
5636 pan_style = vbound(d2,0,3);
5637 // text_mode(vc(11));
5638 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5639 return D_O_K;
5640 }
5641
5642 int32_t set_buf(void *dp3, int32_t d2)
5643 {
5644 // text_mode(vc(11));
5645 zcmusic_bufsz = d2 + 1;
5646 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5647 return D_O_K;
5648 }
5649
5650 static int32_t gamepad_btn_list[] =
5651 {
5652 6,
5653 7,8,9,10,11,12,13,14,15,16,17,
5654 18,19,20,21,22,23,24,25,26,27,28,
5655 29,30,31,32,33,34,35,36,37,38,39,
5656 -1
5657 };
5658
5659 static int32_t gamepad_dirs_list[] =
5660 {
5661 40,41,42,43,
5662 44,45,46,47,
5663 48,49,50,51,
5664 52,53,54,55,
5665 56,
5666 -1
5667 };
5668
5669 static TABPANEL gamepad_tabs[] =
5670 {
5671 // (text)
5672 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5673 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5674 { NULL, 0, NULL, 0, NULL }
5675 };
5676
5677 static DIALOG gamepad_dlg[] =
5678 {
5679 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5680 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5681 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5682 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5683 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5684 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5685 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5686 // 6
5687 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5688 // 7
5689 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5690 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5691 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5692 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5693 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5694 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5695 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5696 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5697 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5698 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5699 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5700 // 18
5701 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5702 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5703 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5704 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5705 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5706 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5707 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5708 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5709 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5710 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5711 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5712 // 29
5713 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5714 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5715 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5716 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5717 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5718 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5719 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5720 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5721 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5722 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5723 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5724 // 40
5725 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5726 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5727 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5728 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5729 // 44
5730 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5731 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5732 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5733 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5734 // 48
5735 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5736 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5737 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5738 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5739 // 52
5740 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5741 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5742 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5743 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5744 // 56
5745 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5746 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5747 };
5748
5749 static int32_t keyboard_keys_list[] =
5750 {
5751 6,7,8,9,10,
5752 11,12,13,14,15,16,17,18,19,20,
5753 21,22,23,24,25,26,27,28,29,30,
5754 31,32,33,34,35,36,37,38,39,40,
5755 -1
5756 };
5757
5758 static int32_t keyboard_dirs_list[] =
5759 {
5760 41,42,43,44,
5761 45,46,47,48,
5762 49,50,51,52,
5763 53,54,55,56,
5764 -1
5765 };
5766
5767 static int32_t keyboard_mods_list[] =
5768 {
5769 57,58,59,60,
5770 61,62,63,64,
5771 65,66,67,68,
5772 69,70,71,72,
5773 -1
5774 };
5775
5776 static TABPANEL keyboard_control_tabs[] =
5777 {
5778 // (text)
5779 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5780 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5781 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5782 { NULL, 0, NULL, 0, NULL }
5783 };
5784
5785 static DIALOG keyboard_control_dlg[] =
5786 {
5787 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5788 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5789 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5790 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5791 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5792 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5793 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5794 // Keys
5795 // 6
5796 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5797 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5798 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5799 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5800 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5801 // 11
5802 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5803 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5804 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5805 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5806 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5807 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5808 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5809 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5810 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5811 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5812 // 21
5813 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5814 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5815 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5816 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5817 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5818 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5819 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5820 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5821 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5822 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5823 // 31
5824 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5825 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5826 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5827 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5828 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5829 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5830 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5831 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5832 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5833 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5834 // Dirs
5835 // 41
5836 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5837 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5838 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5839 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5840 // 45
5841 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5842 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5843 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5844 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5845 // 49
5846 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5847 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5848 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5849 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5850 // 53
5851 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5852 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5853 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5854 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5855 // Mods
5856 // 57
5857 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5858 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5859 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5860 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5861 // 61
5862 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5863 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5864 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5865 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5866 // 65
5867 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5868 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5869 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5870 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5871 // 69
5872 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5873 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5874 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5875 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5876 // 73
5877 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5878 };
5879
5880 /*
5881 int32_t midi_dp[3] = {0,147,104};
5882 int32_t digi_dp[3] = {1,147,120};
5883 int32_t pan_dp[3] = {0,147,136};
5884 int32_t buf_dp[3] = {0,147,152};
5885 */
5886 int32_t midi_dp[3] = {0,0,0};
5887 int32_t digi_dp[3] = {1,0,0};
5888 int32_t emus_dp[3] = {2,0,0};
5889 int32_t buf_dp[3] = {0,0,0};
5890 int32_t sfx_dp[3] = {3,0,0};
5891 int32_t pan_dp[3] = {0,0,0};
5892
5893 static DIALOG sound_dlg[] =
5894 {
5895 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5896 33 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5897 33 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5898 33 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5899 33 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5900 33 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5901 33 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5902 33 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5903 33 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5904 33 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5905 33 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5906 // 10
5907 33 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5908 33 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5909 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5910 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5911 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5912 33 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5913 33 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5914 33 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5915 33 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5916 33 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5917 //20
5918 33 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5919 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5920 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5921 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5922 33 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5923 33 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5924 33 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5925 33 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5926 33 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5927 33 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5928 //30
5929 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5930 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5931 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5932 33 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5933 };
5934
5935 char zc_builddate[80];
5936 char zc_aboutstr[80];
5937
5938 static DIALOG about_dlg[] =
5939 {
5940 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5941 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5942 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5943 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5944 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5945 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5946 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5947 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5948 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5949 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5950 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5951 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5952 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5953 };
5954
5955
5956 static DIALOG quest_dlg[] =
5957 {
5958 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5959 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5960 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5961 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5962 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5963 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5964 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5965 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5966 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5967 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5968 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5969 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5970 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5971 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5972 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5973 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5974 };
5975
5976 static DIALOG triforce_dlg[] =
5977 {
5978 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5979 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5980 // 1
5981 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5982 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5983 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5984 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5985 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5986 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5987 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5988 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5989 // 9
5990 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5991 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5992 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5993 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5994 };
5995
5996 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5997 {
5998 go();
5999 int32_t ret=0;
6000 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6001 comeback();
6002 return ret != 0;
6003 }
6004
6005
6006 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6007 {
6008 if(def!=modulepath)
6009 strcpy(modulepath,def);
6010
6011 if(!usefilename)
6012 {
6013 int32_t i=(int32_t)strlen(modulepath);
6014
6015 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6016 modulepath[i--]=0;
6017 }
6018
6019 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6020 int32_t ret=0;
6021 int32_t sel=0;
6022
6023 if(list==NULL)
6024 {
6025 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6026 }
6027 else
6028 {
6029 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6030 }
6031
6032 return ret!=0;
6033 }
6034
6035 //The Dialogue that loads a ZMOD Module File
6036 int32_t zc_load_zmod_module_file()
6037 {
6038 if ( Playing )
6039 {
6040 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6041 return -1;
6042 }
6043 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6044 return D_CLOSE;
6045
6046 FILE *tempmodule = fopen(modulepath,"r");
6047
6048 if(tempmodule == NULL)
6049 {
6050 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6051 return -1;
6052 }
6053
6054
6055 //Set the module path:
6056 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6057 strcpy(moduledata.module_name, modulepath);
6058 al_trace("New Module Path is: %s \n", moduledata.module_name);
6059 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6060 zcm.init(true); //Load the module values.
6061 moduledata.refresh_title_screen = 1;
6062 // refresh_select_screen = 1;
6063 build_biic_list();
6064 return D_O_K;
6065 }
6066
6067 static DIALOG module_info_dlg[] =
6068 {
6069 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6070
6071
6072 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6073 //1
6074 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6075 //2
6076 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6077 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6078 //4
6079 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6080 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6081 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6082 //7
6083
6084 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6085 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6086 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6087 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6088 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6089 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6090 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6091 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6092 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6093
6094 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6095 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6096 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6097 };
6098
6099 void about_zcplayer_module(const char *prompt,int32_t initialval)
6100 {
6101
6102 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
6103 if ( moduledata.moduletitle[0] != 0 )
6104 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6105
6106 if ( moduledata.moduleauthor[0] != 0 )
6107 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6108
6109 if ( moduledata.moduleinfo0[0] != 0 )
6110 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6111 if ( moduledata.moduleinfo1[0] != 0 )
6112 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6113 if ( moduledata.moduleinfo2[0] != 0 )
6114 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6115 if ( moduledata.moduleinfo3[0] != 0 )
6116 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6117 if ( moduledata.moduleinfo4[0] != 0 )
6118 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6119
6120 char module_date[255];
6121 memset(module_date, 0, sizeof(module_date));
6122 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6123 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6124
6125
6126
6127 char module_vers[255];
6128 memset(module_vers, 0, sizeof(module_vers));
6129 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6130
6131
6132 //sprintf(tilecount,"%d",1);
6133
6134 char module_build[255];
6135 memset(module_build, 0, sizeof(module_build));
6136 if ( moduledata.modbeta )
6137 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6138 else
6139 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6140
6141 module_info_dlg[12].dp = (char*)module_date;
6142 module_info_dlg[13].dp = (char*)module_vers;
6143 module_info_dlg[14].dp = (char*)module_build;
6144
6145 large_dialog(module_info_dlg);
6146
6147 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6148 jwin_center_dialog(module_info_dlg);
6149
6150
6151 }
6152
6153 int32_t onAbout_ZCP_Module()
6154 {
6155 about_zcplayer_module("About Module (.zmod)", 0);
6156 return D_O_K;
6157 }
6158
6159 //New Modules Menu for 2.55+
6160 static MENU zcmodule_menu[] =
6161 {
6162 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6163 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6164
6165 { NULL, NULL, NULL, 0, NULL }
6166 };
6167
6168 int32_t onToggleRecordingNewSaves()
6169 {
6170 if (zc_get_config("zeldadx", "replay_new_saves", false))
6171 {
6172 zc_set_config("zeldadx", "replay_new_saves", false);
6173 }
6174 else
6175 {
6176 zc_set_config("zeldadx", "replay_new_saves", true);
6177 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6178 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6179 }
6180 return D_O_K;
6181 }
6182
6183 int32_t onToggleSnapshotAllFrames()
6184 {
6185 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6186 return D_O_K;
6187 }
6188
6189 int32_t onStopReplayOrRecord()
6190 {
6191 if (replay_is_replaying())
6192 {
6193 replay_quit();
6194 }
6195 else if (replay_get_mode() == ReplayMode::Record)
6196 {
6197 if (!replay_get_meta_bool("test_mode"))
6198 {
6199 jwin_alert("Recording", "You cannot stop recording a save file.",
6200 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6201 return D_CLOSE;
6202 }
6203
6204 if (jwin_alert("Stop Recording",
6205 "Save replay to disk and stop recording?",
6206 "This will stop the recording.",
6207 NULL,
6208 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6209 return D_CLOSE;
6210
6211 replay_save();
6212 replay_stop();
6213 }
6214 return D_O_K;
6215 }
6216
6217 static int32_t handle_on_load_replay(ReplayMode mode)
6218 {
6219 if (Playing)
6220 {
6221 if (jwin_alert("Replay - Warning!",
6222 "Loading a replay will exit the current game.",
6223 "All unsaved progress will be lost.",
6224 "Do you wish to continue?",
6225 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6226 return D_CLOSE;
6227 }
6228
6229 std::string mode_string = replay_mode_to_string(mode);
6230 mode_string[0] = std::toupper(mode_string[0]);
6231
6232 std::string line_1 = "Select a replay file to play back.";
6233 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6234 std::string line_3 = "You can stop the replay and take over manually any time.";
6235 if (mode == ReplayMode::Update)
6236 {
6237 line_1 = "Select a replay file to update.";
6238 line_2 = "WARNING: be sure to back up the zplay file";
6239 line_3 = "and verify that the updated replay works as expected!";
6240 }
6241
6242 if (jwin_alert(mode_string.c_str(),
6243 line_1.c_str(),
6244 line_2.c_str(),
6245 line_3.c_str(),
6246 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6247 {
6248 char replay_path[2048];
6249 strcpy(replay_path, "replays/");
6250 if (jwin_file_select_ex(
6251 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6252 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6253 return D_CLOSE;
6254
6255 replay_quit();
6256 load_replay_file_deferred(mode, replay_path);
6257 Quit = qRESET;
6258 return D_CLOSE;
6259 }
6260 return D_O_K;
6261 }
6262
6263 int32_t onLoadReplay()
6264 {
6265 return handle_on_load_replay(ReplayMode::Replay);
6266 }
6267
6268 int32_t onLoadReplayAssert()
6269 {
6270 return handle_on_load_replay(ReplayMode::Assert);
6271 }
6272
6273 int32_t onLoadReplayUpdate()
6274 {
6275 return handle_on_load_replay(ReplayMode::Update);
6276 }
6277
6278 int32_t onSaveReplay()
6279 {
6280 if (replay_get_mode() == ReplayMode::Record)
6281 {
6282 if (!replay_get_meta_bool("test_mode"))
6283 {
6284 if (jwin_alert("Save Replay",
6285 "This will save a copy of the replay up to this point.",
6286 "The official replay file will be untouched.",
6287 "Do you wish to continue?",
6288 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6289 return D_CLOSE;
6290
6291 char replay_path[2048];
6292 strcpy(replay_path, replay_get_replay_path().string().c_str());
6293 if (jwin_file_select_ex(
6294 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6295 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6296 return D_CLOSE;
6297
6298 if (fileexists(replay_path))
6299 {
6300 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6301 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6302 return D_CLOSE;
6303 }
6304
6305 replay_save(replay_path);
6306 }
6307 else
6308 {
6309 replay_save();
6310 }
6311 }
6312 return D_O_K;
6313 }
6314
6315 static MENU replay_menu[] =
6316 {
6317 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6318 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6319 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6320 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6321 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6322 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6323 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6324
6325 { NULL, NULL, NULL, 0, NULL }
6326 };
6327
6328 static DIALOG credits_dlg[] =
6329 {
6330 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6331 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6332 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6333 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6334 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6335 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6336 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6337 };
6338
6339 33 static ListData dmap_list(dmaplist, &font);
6340
6341 static DIALOG goto_dlg[] =
6342 {
6343 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6344 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6345 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6346 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6347 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6348 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6349 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6350 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6351 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6352 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6353 };
6354
6355 int32_t onGoTo()
6356 {
6357 bool music = false;
6358 music = music;
6359 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6360
6361 goto_dlg[0].dp2=get_zc_font(font_lfont);
6362 goto_dlg[4].d2=cheat_goto_dmap;
6363 goto_dlg[6].dp=cheat_goto_screen_str;
6364
6365 clear_keybuf();
6366
6367 large_dialog(goto_dlg);
6368
6369 if(zc_popup_dialog(goto_dlg,4)==1)
6370 {
6371 // dmap, screen
6372 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6373 };
6374
6375 return D_O_K;
6376 }
6377
6378 int32_t onGoToComplete()
6379 {
6380 if(!Playing)
6381 {
6382 return D_O_K;
6383 }
6384
6385 system_pal();
6386 music_pause();
6387 pause_all_sfx();
6388 sys_mouse();
6389 onGoTo();
6390 eat_buttons();
6391
6392 zc_readrawkey(KEY_ESC);
6393
6394 game_mouse();
6395 game_pal();
6396 music_resume();
6397 resume_all_sfx();
6398 return D_O_K;
6399 }
6400
6401 int32_t onCredits()
6402 {
6403 go();
6404
6405 BITMAP *win = create_bitmap_ex(8,222,110);
6406
6407 if(!win)
6408 return D_O_K;
6409
6410 int32_t c=0;
6411 int32_t l=0;
6412 int32_t ol=-1;
6413 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6414 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6415 PALETTE tmppal;
6416
6417 rti_gui.transparency_index = 1;
6418
6419 clear_to_color(win, rti_gui.transparency_index);
6420 draw_rle_sprite(win,rle,0,0);
6421 credits_dlg[0].dp2=get_zc_font(font_lfont);
6422 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6423 credits_dlg[2].dp = win;
6424
6425 zc_set_palette_range(black_palette,0,127,false);
6426
6427 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6428
6429 BITMAP* old_screen = screen;
6430 BITMAP* gui_bmp = zc_get_gui_bmp();
6431 ASSERT(gui_bmp);
6432 clear_to_color(gui_bmp, rti_gui.transparency_index);
6433 screen = gui_bmp;
6434
6435 while(update_dialog(p))
6436 {
6437 throttleFPS();
6438 ++c;
6439 l = zc_max((c>>1)-30,0);
6440
6441 if(l > rle->h)
6442 l = c = 0;
6443
6444 if(l > rle->h - 112)
6445 l = rle->h - 112;
6446
6447 clear_bitmap(win);
6448 draw_rle_sprite(win,rle,0,0-l);
6449
6450 if(c<=64)
6451 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6452
6453 zc_set_palette_range(tmppal,0,127,false);
6454
6455 if(l!=ol)
6456 {
6457 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6458 SCRFIX();
6459 ol=l;
6460 }
6461
6462 update_hw_screen();
6463 }
6464
6465 screen = old_screen;
6466 system_pal();
6467
6468 shutdown_dialog(p);
6469 destroy_bitmap(win);
6470 //comeback();
6471
6472 rti_gui.transparency_index = 0;
6473 clear_to_color(gui_bmp, rti_gui.transparency_index);
6474
6475 return D_O_K;
6476 }
6477
6478 const char *midilist(int32_t index, int32_t *list_size)
6479 {
6480 if(index<0)
6481 {
6482 *list_size=0;
6483
6484 for(int32_t i=0; i<MAXMIDIS; i++)
6485 if(tunes[i].data)
6486 ++(*list_size);
6487
6488 return NULL;
6489 }
6490
6491 int32_t i=0,m=0;
6492
6493 while(m<=index && i<=MAXMIDIS)
6494 {
6495 if(tunes[i].data)
6496 ++m;
6497
6498 ++i;
6499 }
6500
6501 --i;
6502
6503 if(i==MAXMIDIS && m<index)
6504 return "(null)";
6505
6506 return tunes[i].title;
6507 }
6508
6509 /* ------- MIDI info stuff -------- */
6510
6511 char *text;
6512 midi_info *zmi;
6513 bool dialog_running;
6514 bool listening;
6515
6516 void get_info(int32_t index);
6517
6518 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6519 {
6520 int32_t d2 = d->d2;
6521 int32_t ret = jwin_droplist_proc(msg,d,c);
6522
6523 if(d2!=d->d2)
6524 {
6525 get_info(d->d2);
6526 }
6527
6528 return ret;
6529 }
6530
6531 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6532 {
6533 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6534
6535 int32_t ret = jwin_button_proc(msg,d,c);
6536
6537 if(ret == D_CLOSE)
6538 {
6539 // get current midi index
6540 int32_t index = (d+(d->d1))->d2;
6541 int32_t i=0, m=0;
6542
6543 while(m<=index && i<=MAXMIDIS)
6544 {
6545 if(tunes[i].data)
6546 ++m;
6547
6548 ++i;
6549 }
6550
6551 --i;
6552 jukebox(i);
6553 listening = true;
6554 ret = D_O_K;
6555 }
6556
6557 return ret;
6558 }
6559
6560 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6561 {
6562 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6563
6564 int32_t ret = jwin_button_proc(msg,d,c);
6565
6566 if(ret == D_CLOSE)
6567 {
6568 // get current midi index
6569 int32_t index = (d+(d->d1))->d2;
6570 int32_t i=0, m=0;
6571
6572 while(m<=index && i<=MAXMIDIS)
6573 {
6574 if(tunes[i].data)
6575 ++m;
6576
6577 ++i;
6578 }
6579
6580 --i;
6581
6582 // get file name
6583
6584 int32_t sel=0;
6585 //struct ffblk f;
6586 char title[40] = "Save MIDI: ";
6587 char fname[2048];
6588 memset(fname,0,2048);
6589 static EXT_LIST list[] =
6590 {
6591 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6592 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6593 { NULL, NULL }
6594 };
6595
6596 strcpy(title+11, tunes[i].title);
6597 title[39] = '\0';
6598
6599 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6600 goto done;
6601
6602 if(exists(fname))
6603 {
6604 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6605 goto done;
6606 }
6607
6608 // save midi i
6609
6610 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6611 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6612
6613 done:
6614 chop_path(fname);
6615 ret = D_REDRAW;
6616 }
6617
6618 return ret;
6619 }
6620
6621 33 static ListData midi_list(midilist, &font);
6622
6623 static DIALOG midi_dlg[] =
6624 {
6625 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6626 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6627 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6628 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6629 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6630 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6631 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6632 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6633 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6634 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6635 };
6636
6637 void get_info(int32_t index)
6638 {
6639 int32_t i=0, m=0;
6640
6641 while(m<=index && i<=MAXMIDIS)
6642 {
6643 if(tunes[i].data)
6644 ++m;
6645
6646 ++i;
6647 }
6648
6649 --i;
6650
6651 if(i==MAXMIDIS && m<index)
6652 strcpy(text,"(null)");
6653 else
6654 {
6655 get_midi_info((MIDI*)tunes[i].data,zmi);
6656 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6657 }
6658
6659 midi_dlg[0].dp2=get_zc_font(font_lfont);
6660 midi_dlg[3].dp = text;
6661 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6662 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6663
6664 if(dialog_running)
6665 {
6666 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6667 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6668 }
6669 }
6670
6671 int32_t onMIDICredits()
6672 {
6673 text = (char*)malloc(4096);
6674 zmi = (midi_info*)malloc(sizeof(midi_info));
6675
6676 if(!text || !zmi)
6677 {
6678 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6679 return D_O_K;
6680 }
6681
6682 bool do_pause_midi = midi_pos >= 0 && currmidi;
6683 auto restore_midi = currmidi;
6684 if(do_pause_midi)
6685 {
6686 paused_midi_pos = midi_pos;
6687 stop_midi();
6688 midi_paused=true;
6689 midi_suspended = midissuspHALTED;
6690 }
6691
6692 midi_dlg[0].dp2=get_zc_font(font_lfont);
6693 midi_dlg[2].d1 = 0;
6694 midi_dlg[2].d2 = 0;
6695 midi_dlg[4].flags = D_EXIT;
6696 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6697
6698 listening = false;
6699 dialog_running=false;
6700 get_info(0);
6701
6702 dialog_running=true;
6703
6704 large_dialog(midi_dlg);
6705
6706 zc_popup_dialog(midi_dlg,0);
6707 dialog_running=false;
6708
6709 if(listening)
6710 music_stop();
6711
6712 if(do_pause_midi)
6713 {
6714 midi_suspended = midissuspRESUME;
6715 currmidi = restore_midi;
6716 midi_pos = paused_midi_pos;
6717 }
6718
6719 if(text) free(text);
6720 if(zmi) free(zmi);
6721 return D_O_K;
6722 }
6723
6724 int32_t onAbout()
6725 {
6726 char buf1[80]={0};
6727 std::ostringstream oss;
6728 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6729 oss << buf1 << '\n';
6730 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6731 oss << buf1 << '\n';
6732 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6733 oss << buf1 << '\n';
6734 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6735 oss << buf1 << '\n';
6736 sprintf(buf1, "Tag: %s", getReleaseTag());
6737 oss << buf1 << '\n';
6738
6739 InfoDialog("About ZC", oss.str()).show();
6740 return D_O_K;
6741 }
6742
6743 int32_t onQuest()
6744 {
6745 char fname[100];
6746 strcpy(fname, get_filename(qstpath));
6747 quest_dlg[0].dp2=get_zc_font(font_lfont);
6748 quest_dlg[1].dp = fname;
6749
6750 if(QHeader.quest_number==0)
6751 sprintf(str_a,"Custom");
6752 else
6753 sprintf(str_a,"%d",QHeader.quest_number);
6754
6755 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6756
6757 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6758 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6759
6760 large_dialog(quest_dlg);
6761
6762 zc_popup_dialog(quest_dlg, 0);
6763 return D_O_K;
6764 }
6765
6766 void call_vidmode_dlg();
6767 int32_t onVidMode()
6768 {
6769 call_vidmode_dlg();
6770 return D_O_K;
6771 }
6772
6773 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6774 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6775 //Added an extra statement, so that if the key is cleared to 0, the cleared
6776 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6777
6778 void load_ukeys(int32_t* arr)
6779 {
6780 arr[ukey_a] = Akey;
6781 arr[ukey_b] = Bkey;
6782 arr[ukey_s] = Skey;
6783 arr[ukey_l] = Lkey;
6784 arr[ukey_r] = Rkey;
6785 arr[ukey_p] = Pkey;
6786 arr[ukey_ex1] = Exkey1;
6787 arr[ukey_ex2] = Exkey2;
6788 arr[ukey_ex3] = Exkey3;
6789 arr[ukey_ex4] = Exkey4;
6790 arr[ukey_du] = DUkey;
6791 arr[ukey_dd] = DDkey;
6792 arr[ukey_dl] = DLkey;
6793 arr[ukey_dr] = DRkey;
6794 arr[ukey_mod1a] = cheat_modifier_keys[0];
6795 arr[ukey_mod1b] = cheat_modifier_keys[1];
6796 arr[ukey_mod2a] = cheat_modifier_keys[2];
6797 arr[ukey_mod2b] = cheat_modifier_keys[3];
6798 };
6799
6800 static const char* ukey_names[] = {
6801 "A", "B", "Start", "L", "R", "Map",
6802 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6803 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6804 "Cheat Mod R1", "Cheat Mod R2",
6805 };
6806 std::string get_ukey_name(int32_t k)
6807 {
6808 if (k < num_ukey) return ukey_names[k];
6809 return "";
6810 }
6811
6812 int32_t onKeyboard()
6813 {
6814 int32_t a = Akey;
6815 int32_t b = Bkey;
6816 int32_t s = Skey;
6817 int32_t l = Lkey;
6818 int32_t r = Rkey;
6819 int32_t p = Pkey;
6820 int32_t ex1 = Exkey1;
6821 int32_t ex2 = Exkey2;
6822 int32_t ex3 = Exkey3;
6823 int32_t ex4 = Exkey4;
6824 int32_t du = DUkey;
6825 int32_t dd = DDkey;
6826 int32_t dl = DLkey;
6827 int32_t dr = DRkey;
6828 int32_t mod1a = cheat_modifier_keys[0];
6829 int32_t mod1b = cheat_modifier_keys[1];
6830 int32_t mod2a = cheat_modifier_keys[2];
6831 int32_t mod2b = cheat_modifier_keys[3];
6832 bool done=false;
6833 int32_t ret;
6834
6835 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6836
6837 large_dialog(keyboard_control_dlg);
6838
6839 while(!done)
6840 {
6841 ret = zc_popup_dialog(keyboard_control_dlg,3);
6842
6843 if(ret==3) // OK
6844 {
6845 int32_t ukeys[num_ukey];
6846 load_ukeys(ukeys);
6847 std::vector<std::string> uniqueError;
6848 for(int32_t q = 0; q < num_ukey; ++q)
6849 {
6850 for(int32_t p = q+1; p < num_ukey; ++p)
6851 {
6852 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6853 {
6854 char buf[64];
6855 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6856 std::string str(buf);
6857 uniqueError.push_back(str);
6858 }
6859 }
6860 }
6861 if(uniqueError.size() == 0)
6862 {
6863 done = true;
6864 save_control_configs(true);
6865 }
6866 else
6867 {
6868 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6869 box_out("Cannot have duplicate keybinds!"); box_eol();
6870 for(std::vector<std::string>::iterator it = uniqueError.begin();
6871 it != uniqueError.end(); ++it)
6872 {
6873 box_out((*it).c_str()); box_eol();
6874 }
6875 box_end(true);
6876 }
6877 }
6878 else // Cancel
6879 {
6880 Akey = a;
6881 Bkey = b;
6882 Skey = s;
6883 Lkey = l;
6884 Rkey = r;
6885 Pkey = p;
6886 Exkey1 = ex1;
6887 Exkey2 = ex2;
6888 Exkey3 = ex3;
6889 Exkey4 = ex4;
6890 DUkey = du;
6891 DDkey = dd;
6892 DLkey = dl;
6893 DRkey = dr;
6894 cheat_modifier_keys[0] = mod1a;
6895 cheat_modifier_keys[1] = mod1b;
6896 cheat_modifier_keys[2] = mod2a;
6897 cheat_modifier_keys[3] = mod2b;
6898
6899 done=true;
6900 }
6901
6902 rest(1);
6903 }
6904
6905 return D_O_K;
6906 }
6907
6908 int32_t onGamepad()
6909 {
6910 int32_t a = Abtn;
6911 int32_t b = Bbtn;
6912 int32_t s = Sbtn;
6913 int32_t l = Lbtn;
6914 int32_t r = Rbtn;
6915 int32_t m = Mbtn;
6916 int32_t p = Pbtn;
6917 int32_t ex1 = Exbtn1;
6918 int32_t ex2 = Exbtn2;
6919 int32_t ex3 = Exbtn3;
6920 int32_t ex4 = Exbtn4;
6921 int32_t up = DUbtn;
6922 int32_t down = DDbtn;
6923 int32_t left = DLbtn;
6924 int32_t right = DRbtn;
6925
6926 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6927 if(analog_movement)
6928 gamepad_dlg[56].flags|=D_SELECTED;
6929 else
6930 gamepad_dlg[56].flags&=~D_SELECTED;
6931
6932 large_dialog(gamepad_dlg);
6933
6934 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6935
6936 if(ret == 4) //OK
6937 {
6938 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6939 save_control_configs(false);
6940 }
6941 else //Cancel
6942 {
6943 Abtn = a;
6944 Bbtn = b;
6945 Sbtn = s;
6946 Lbtn = l;
6947 Rbtn = r;
6948 Mbtn = m;
6949 Pbtn = p;
6950 Exbtn1 = ex1;
6951 Exbtn2 = ex2;
6952 Exbtn3 = ex3;
6953 Exbtn4 = ex4;
6954 DUbtn = up;
6955 DDbtn = down;
6956 DLbtn = left;
6957 DRbtn = right;
6958 }
6959
6960 return D_O_K;
6961 }
6962
6963 int32_t onCheatKeys()
6964 {
6965 int32_t oldcheats[Cheat::Last][2];
6966 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6967
6968 bool done=false;
6969
6970 while(!done)
6971 {
6972 bool confirm = false;
6973 CheatKeysDialog(&confirm).show();
6974 if(confirm) // OK
6975 {
6976 std::vector<std::string> uniqueError;
6977 char buf[512];
6978 for(size_t q = 1; q < Cheat::Last; ++q)
6979 {
6980 if(cheatkeys[q][1] && !cheatkeys[q][0])
6981 {
6982 cheatkeys[q][0] = cheatkeys[q][1];
6983 cheatkeys[q][1] = 0;
6984 }
6985 }
6986 for(size_t q = 1; q < Cheat::Last; ++q)
6987 {
6988 if(!bindable_cheat((Cheat)q)) continue;
6989 for(size_t p = q+1; p < Cheat::Last; ++p)
6990 {
6991 if(!bindable_cheat((Cheat)p)) continue;
6992 for(size_t q2 = 0; q2 <= 1; ++q2)
6993 for(size_t p2 = 0; p2 <= 1; ++p2)
6994 {
6995 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6996 {
6997 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6998 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6999 cheat_to_string((Cheat)p), p2?"Alt":"Main",
7000 get_keystr(cheatkeys[q][q2])));
7001 }
7002 }
7003 }
7004 }
7005 if(uniqueError.size() == 0)
7006 {
7007 done = true;
7008 save_cheatkeys();
7009 }
7010 else
7011 {
7012 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
7013 box_out("Cannot have duplicate keybinds!"); box_eol();
7014 for(std::vector<std::string>::iterator it = uniqueError.begin();
7015 it != uniqueError.end(); ++it)
7016 {
7017 box_out((*it).c_str()); box_eol();
7018 }
7019 box_end(true);
7020 }
7021 }
7022 else // Cancel
7023 {
7024 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
7025 done=true;
7026 }
7027 rest(1);
7028 }
7029
7030 return D_O_K;
7031 }
7032
7033 int32_t onSound()
7034 {
7035 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7036 {
7037 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7038 }
7039 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7040 {
7041 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7042 }
7043 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7044 {
7045 emusic_volume = (int32_t)FFCore.usr_music_volume;
7046 }
7047 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7048 {
7049 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7050 }
7051 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7052 {
7053 pan_style = (int32_t)FFCore.usr_panstyle;
7054 }
7055
7056 int32_t m = midi_volume;
7057 int32_t d = digi_volume;
7058 int32_t e = emusic_volume;
7059 int32_t b = zcmusic_bufsz;
7060 int32_t s = sfx_volume;
7061 int32_t p = pan_style;
7062 pan_style = vbound(pan_style,0,3);
7063
7064 sound_dlg[0].dp2=get_zc_font(font_lfont);
7065
7066 large_dialog(sound_dlg);
7067
7068 midi_dp[1] = sound_dlg[6].x;
7069 midi_dp[2] = sound_dlg[6].y;
7070 digi_dp[1] = sound_dlg[7].x;
7071 digi_dp[2] = sound_dlg[7].y;
7072 emus_dp[1] = sound_dlg[8].x;
7073 emus_dp[2] = sound_dlg[8].y;
7074 buf_dp[1] = sound_dlg[9].x;
7075 buf_dp[2] = sound_dlg[9].y;
7076 sfx_dp[1] = sound_dlg[10].x;
7077 sfx_dp[2] = sound_dlg[10].y;
7078 pan_dp[1] = sound_dlg[11].x;
7079 pan_dp[2] = sound_dlg[11].y;
7080 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7081 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7082 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7083 sound_dlg[18].d2 = zcmusic_bufsz;
7084 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7085 sound_dlg[20].d2 = pan_style;
7086
7087 int32_t ret = zc_popup_dialog(sound_dlg,1);
7088
7089 if(ret==2)
7090 {
7091 master_volume(digi_volume,midi_volume);
7092
7093 for(int32_t i=0; i<WAV_COUNT; ++i)
7094 {
7095 //allegro assertion fails when passing in -1 as voice -DD
7096 if(sfx_voice[i] > 0)
7097 voice_set_volume(sfx_voice[i], sfx_volume);
7098 }
7099 zc_set_config(sfx_sect,"digi",digi_volume);
7100 zc_set_config(sfx_sect,"midi",midi_volume);
7101 zc_set_config(sfx_sect,"sfx",sfx_volume);
7102 zc_set_config(sfx_sect,"emusic",emusic_volume);
7103 zc_set_config(sfx_sect,"pan",pan_style);
7104 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7105 }
7106 else
7107 {
7108 midi_volume = m;
7109 digi_volume = d;
7110 emusic_volume = e;
7111 zcmusic_bufsz = b;
7112 sfx_volume = s;
7113 pan_style = p;
7114 }
7115
7116 return D_O_K;
7117 }
7118
7119 int32_t queding(char const* s1, char const* s2, char const* s3)
7120 {
7121 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7122 }
7123
7124 int32_t onQuit()
7125 {
7126 if(Playing)
7127 {
7128 int32_t ret=0;
7129
7130 if(get_bit(quest_rules, qr_NOCONTINUE))
7131 {
7132 if(standalone_mode)
7133 {
7134 ret=queding("End current game?",
7135 "The continue screen is disabled; the game",
7136 "will be reloaded from the last save.");
7137 }
7138 else
7139 {
7140 ret=queding("End current game?",
7141 "The continue screen is disabled. You will",
7142 "be returned to the file select screen.");
7143 }
7144 }
7145 else
7146 ret=queding("End current game?",NULL,NULL);
7147
7148 if(ret==1)
7149 {
7150 disableClickToFreeze=false;
7151 Quit=qQUIT;
7152
7153 // Trying to evade a door repair charge?
7154 if(repaircharge)
7155 {
7156 game->change_drupy(-repaircharge);
7157 repaircharge=0;
7158 }
7159
7160 return D_CLOSE;
7161 }
7162 }
7163
7164 return D_O_K;
7165 }
7166
7167 int32_t onTryQuitMenu()
7168 {
7169 return onTryQuit(true);
7170 }
7171
7172 int32_t onTryQuit(bool inMenu)
7173 {
7174 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7175 {
7176 if(active_cutscene.can_f6())
7177 {
7178 if(get_bit(quest_rules,qr_OLD_F6))
7179 {
7180 if(inMenu) onQuit();
7181 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7182 }
7183 else
7184 {
7185 disableClickToFreeze=false;
7186 GameFlags |= GAMEFLAG_TRYQUIT;
7187 }
7188 return D_CLOSE;
7189 }
7190 else active_cutscene.error();
7191 }
7192
7193 return D_O_K;
7194 }
7195
7196 int32_t onReset()
7197 {
7198 if(queding(" Reset system? ",NULL,NULL)==1)
7199 {
7200 disableClickToFreeze=false;
7201 Quit=qRESET;
7202 replay_quit();
7203 return D_CLOSE;
7204 }
7205
7206 return D_O_K;
7207 }
7208
7209 int32_t onExit()
7210 {
7211 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7212 {
7213 Quit=qEXIT;
7214 return D_CLOSE;
7215 }
7216
7217 return D_O_K;
7218 }
7219
7220 int32_t onTitle_NES()
7221 {
7222 title_version=0;
7223 zc_set_config(cfg_sect,"title",title_version);
7224 return D_O_K;
7225 }
7226 int32_t onTitle_DX()
7227 {
7228 title_version=1;
7229 zc_set_config(cfg_sect,"title",title_version);
7230 return D_O_K;
7231 }
7232 int32_t onTitle_25()
7233 {
7234 title_version=2;
7235 zc_set_config(cfg_sect,"title",title_version);
7236 return D_O_K;
7237 }
7238
7239 int32_t onDebug()
7240 {
7241 if(debug_enabled)
7242 set_debug(!get_debug());
7243 return D_O_K;
7244 }
7245
7246 int32_t onHeartBeep()
7247 {
7248 heart_beep=!heart_beep;
7249 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7250 return D_O_K;
7251 }
7252
7253 int32_t onSaveIndicator()
7254 {
7255 use_save_indicator=!use_save_indicator;
7256 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7257 return D_O_K;
7258 }
7259
7260 int32_t onEpilepsy()
7261 {
7262 if(jwin_alert3(
7263 "Epilepsy Flash Reduction",
7264 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7265 "Disabling this will restore standard flash and wavy behaviour.",
7266 "Proceed?",
7267 "&Yes",
7268 "&No",
7269 NULL,
7270 'y',
7271 'n',
7272 0,
7273 get_zc_font(font_lfont)) == 1)
7274 {
7275 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7276 zc_set_config("zeldadx","checked_epilepsy",1);
7277 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7278 }
7279 return D_O_K;
7280 }
7281
7282 int32_t onTriforce()
7283 {
7284 for(int32_t i=0; i<MAXINITTABS; ++i)
7285 {
7286 init_tabs[i].flags&=~D_SELECTED;
7287 }
7288
7289 init_tabs[3].flags=D_SELECTED;
7290 return onCheatConsole();
7291 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7292 for(int32_t i=1; i<=8; i++)
7293 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7294
7295 if(zc_popup_dialog (triforce_dlg,-1)==9)
7296 {
7297 for(int32_t i=1; i<=8; i++)
7298 {
7299 game->lvlitems[i] &= ~liTRIFORCE;
7300 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7301 }
7302 }
7303 return D_O_K;*/
7304 }
7305
7306 bool rc = false;
7307 /*
7308 int32_t onEquipment()
7309 {
7310 for (int32_t i=0; i<MAXINITTABS; ++i)
7311 {
7312 init_tabs[i].flags&=~D_SELECTED;
7313 }
7314 init_tabs[0].flags=D_SELECTED;
7315 return onCheatConsole();
7316 }
7317 */
7318
7319 int32_t onItems()
7320 {
7321 for(int32_t i=0; i<MAXINITTABS; ++i)
7322 {
7323 init_tabs[i].flags&=~D_SELECTED;
7324 }
7325
7326 init_tabs[1].flags=D_SELECTED;
7327 return onCheatConsole();
7328 }
7329
7330 static DIALOG getnum_dlg[] =
7331 {
7332 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7333 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7334 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7335 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7336 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7337 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7338 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7339 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7340 };
7341
7342 int32_t getnumber(const char *prompt,int32_t initialval)
7343 {
7344 char buf[20];
7345 sprintf(buf,"%d",initialval);
7346 getnum_dlg[0].dp=(void *)prompt;
7347 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7348 getnum_dlg[2].dp=buf;
7349
7350 large_dialog(getnum_dlg);
7351
7352 if(zc_popup_dialog(getnum_dlg,2)==3)
7353 return atoi(buf);
7354
7355 return initialval;
7356 }
7357
7358 int32_t onLife()
7359 {
7360 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7361 cheats_enqueue(Cheat::Life, value);
7362 return D_O_K;
7363 }
7364
7365 int32_t onHeartC()
7366 {
7367 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7368 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7369 cheats_enqueue(Cheat::MaxLife, max_life);
7370 cheats_enqueue(Cheat::Life, life);
7371 return D_O_K;
7372 }
7373
7374 int32_t onMagicC()
7375 {
7376 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7377 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7378 cheats_enqueue(Cheat::MaxMagic, max_magic);
7379 cheats_enqueue(Cheat::Magic, magic);
7380 return D_O_K;
7381 }
7382
7383 int32_t onRupies()
7384 {
7385 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7386 cheats_enqueue(Cheat::Rupies, value);
7387 return D_O_K;
7388 }
7389
7390 int32_t onMaxBombs()
7391 {
7392 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7393 cheats_enqueue(Cheat::MaxBombs, value);
7394 cheats_enqueue(Cheat::Bombs, value);
7395 return D_O_K;
7396 }
7397
7398 int32_t onRefillLife()
7399 {
7400 cheats_enqueue(Cheat::Life, game->get_maxlife());
7401 return D_O_K;
7402 }
7403 int32_t onRefillMagic()
7404 {
7405 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7406 return D_O_K;
7407 }
7408 int32_t onClock()
7409 {
7410 cheats_enqueue(Cheat::Clock);
7411 return D_O_K;
7412 }
7413
7414 int32_t onQstPath()
7415 {
7416 char path[2048];
7417
7418 chop_path(qstdir);
7419 strcpy(path,qstdir);
7420
7421 go();
7422
7423 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7424 {
7425 chop_path(path);
7426 fix_filename_case(path);
7427 fix_filename_slashes(path);
7428 strcpy(qstdir,path);
7429 strcpy(qstpath,qstdir);
7430 }
7431
7432 comeback();
7433 return D_O_K;
7434 }
7435
7436 #include "dialog/cheat_dialog.h"
7437 int32_t onCheat()
7438 {
7439 call_setcheat_dialog();
7440 game->set_cheat(maxcheat);
7441 if(cheat) game->did_cheat(true);
7442 return D_O_K;
7443 }
7444
7445 int32_t onCheatRupies()
7446 {
7447 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7448 return D_O_K;
7449 }
7450
7451 int32_t onCheatArrows()
7452 {
7453 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7454 return D_O_K;
7455 }
7456
7457 int32_t onCheatBombs()
7458 {
7459 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7460 return D_O_K;
7461 }
7462
7463 // *** screen saver
7464
7465 8132269 int32_t after_time()
7466 {
7467
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(ss_enable == 0)
7468 return INT_MAX;
7469
7470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
8132269 if(ss_after <= 0)
7471 return 5 * 60;
7472
7473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
8132269 if(ss_after <= 3)
7474 return ss_after * 15 * 60;
7475
7476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
8132269 if(ss_after <= 13)
7477 return (ss_after - 3) * 60 * 60;
7478
7479 8132269 return MAX_IDLE + 1;
7480 8132269 }
7481
7482 static const char *after_str[15] =
7483 {
7484 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7485 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7486 "Never"
7487 };
7488
7489 const char *after_list(int32_t index, int32_t *list_size)
7490 {
7491 if(index < 0)
7492 {
7493 *list_size = 15;
7494 return NULL;
7495 }
7496
7497 return after_str[index];
7498 }
7499
7500 33 static ListData after__list(after_list, &font);
7501
7502 static DIALOG scrsaver_dlg[] =
7503 {
7504 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7505 33 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7506 33 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7507 33 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7508 33 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7509 33 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7510 33 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7511 33 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7512 33 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7513 33 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7514 33 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7515 33 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7516 33 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7517 33 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7518 };
7519
7520 int32_t onScreenSaver()
7521 {
7522 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7523 int32_t oldcfgs[3];
7524 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7525 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7526 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7527
7528 large_dialog(scrsaver_dlg);
7529
7530 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7531
7532 if(ret == 8 || ret == 9)
7533 {
7534 ss_after = scrsaver_dlg[5].d1;
7535 ss_speed = scrsaver_dlg[6].d2;
7536 ss_density = scrsaver_dlg[7].d2;
7537 if(oldcfgs[0] != ss_after)
7538 zc_set_config(cfg_sect,"ss_after",ss_after);
7539 if(oldcfgs[1] != ss_speed)
7540 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7541 if(oldcfgs[2] != ss_density)
7542 zc_set_config(cfg_sect,"ss_density",ss_density);
7543 }
7544
7545 if(ret == 9)
7546 // preview Screen Saver
7547 {
7548 clear_keybuf();
7549 Matrix(ss_speed, ss_density, 30);
7550 system_pal();
7551 }
7552
7553 return D_O_K;
7554 }
7555
7556 /***** Menus *****/
7557
7558 static MENU game_menu[] =
7559 {
7560 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7561 { (char *)"", NULL, NULL, 0, NULL },
7562 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7563 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7564 { (char *)"", NULL, NULL, 0, NULL },
7565 #ifdef __EMSCRIPTEN__
7566 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7567 #elif defined(ALLEGRO_MACOSX)
7568 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7569 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7570 #else
7571 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7572 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7573 #endif
7574 { NULL, NULL, NULL, 0, NULL }
7575 };
7576
7577 static MENU title_menu[] =
7578 {
7579 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7580 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7581 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7582 { NULL, NULL, NULL, 0, NULL }
7583 };
7584
7585 static MENU snapshot_format_menu[] =
7586 {
7587 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7588 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7589 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7590 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7591 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7592 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7593 { NULL, NULL, NULL, 0, NULL }
7594 };
7595
7596 static MENU controls_menu[] =
7597 {
7598 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7599 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7600 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7601 { NULL, NULL, NULL, 0, NULL }
7602 };
7603
7604 static MENU name_entry_mode_menu[] =
7605 {
7606 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7607 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7608 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7609 { NULL, NULL, NULL, 0, NULL }
7610 };
7611
7612 static void set_controls_menu_active()
7613 {
7614
7615 }
7616
7617 static MENU window_menu[] =
7618 {
7619 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7620 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7621 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7622 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7623 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7624 { NULL, NULL, NULL, 0, NULL }
7625 };
7626 static MENU options_menu[] =
7627 {
7628 { "&Title Screen", NULL, title_menu, 0, NULL },
7629 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7630 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7631 { "&Window Settings", NULL, window_menu, 0, NULL },
7632 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7633 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7634 { NULL, NULL, NULL, 0, NULL }
7635 };
7636 static MENU settings_menu[] =
7637 {
7638 { "&Sound...", onSound, NULL, 0, NULL },
7639 { "C&ontrols", NULL, controls_menu, 0, NULL },
7640 { "", NULL, NULL, 0, NULL },
7641 { "Options", NULL, options_menu, 0, NULL },
7642 { "", NULL, NULL, 0, NULL },
7643 //
7644 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7645 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7646 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7647 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7648 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7649 //
7650 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7651 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7652 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7653 { "", NULL, NULL, 0, NULL },
7654 { "Debu&g", onDebug, NULL, 0, NULL },
7655 //
7656 { NULL, NULL, NULL, 0, NULL }
7657 };
7658
7659
7660 static MENU misc_menu[] =
7661 {
7662 { (char *)"&About...", onAbout, NULL, 0, NULL },
7663 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7664 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7665 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7666 { (char *)"", NULL, NULL, 0, NULL },
7667 //5
7668 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7669 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7670 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7671 { (char *)"", NULL, NULL, 0, NULL },
7672 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7673 //10
7674 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7675 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7676 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7677 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7678 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7679 //15
7680 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7681 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7682 { NULL, NULL, NULL, 0, NULL }
7683 };
7684
7685 static MENU refill_menu[] =
7686 {
7687 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7688 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7689 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7690 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7691 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7692 { NULL, NULL, NULL, 0, NULL }
7693 };
7694
7695 static MENU show_menu[] =
7696 {
7697 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7698 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7699 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7700 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7701 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7702 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7703 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7704 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7705 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7706 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7707 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7708 { (char *)"", NULL, NULL, 0, NULL },
7709 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7710 { (char *)"", NULL, NULL, 0, NULL },
7711 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7712 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7713 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7714 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7715 { NULL, NULL, NULL, 0, NULL }
7716 };
7717
7718 static MENU cheat_menu[] =
7719 {
7720 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7721 { (char *)"", NULL, NULL, 0, NULL },
7722 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7723 { (char *)"", NULL, NULL, 0, NULL },
7724 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7725 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7726 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7727 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7728 { (char *)"", NULL, NULL, 0, NULL },
7729 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7730 { (char *)"", NULL, NULL, 0, NULL },
7731 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7732 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7733 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7734 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7735 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7736 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7737 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7738 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7739 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7740 { NULL, NULL, NULL, 0, NULL }
7741 };
7742
7743 #if DEVLEVEL > 0
7744 int32_t devLogging();
7745 int32_t devDebug();
7746 int32_t devTimestmp();
7747 #if DEVLEVEL > 1
7748 int32_t setCheat();
7749 #endif //DEVLEVEL > 1
7750 enum
7751 {
7752 dv_log,
7753 // dv_dbg,
7754 dv_tmpstmp,
7755 #if DEVLEVEL > 1
7756 dv_nil,
7757 dv_setcheat,
7758 #endif //DEVLEVEL > 1
7759 dv_max
7760 };
7761 static MENU dev_menu[] =
7762 {
7763 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7764 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7765 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7766 #if DEVLEVEL > 1
7767 { (char *)"", NULL, NULL, 0, NULL },
7768 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7769 #endif //DEVLEVEL > 1
7770 { NULL, NULL, NULL, 0, NULL }
7771 };
7772 int32_t devLogging()
7773 {
7774 dev_logging = !dev_logging;
7775 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7776 return D_O_K;
7777 }
7778 // int32_t devDebug()
7779 // {
7780 // dev_debug = !dev_debug;
7781 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7782 // return D_O_K;
7783 // }
7784 int32_t devTimestmp()
7785 {
7786 dev_timestmp = !dev_timestmp;
7787 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7788 return D_O_K;
7789 }
7790 #if DEVLEVEL > 1
7791 int32_t setCheat()
7792 {
7793 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7794 return D_O_K;
7795 }
7796 #endif //DEVLEVEL > 1
7797 #endif //DEVLEVEL > 0
7798
7799 MENU the_player_menu[] =
7800 {
7801 { (char *)"&Game", NULL, game_menu, 0, NULL },
7802 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7803 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7804 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7805 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7806 #if DEVLEVEL > 0
7807 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7808 #endif
7809 { NULL, NULL, NULL, 0, NULL }
7810 };
7811 int32_t onMIDIPatch()
7812 {
7813 if(jwin_alert3(
7814 "Toggle Windows MIDI Fix",
7815 "This action will change whether ZC Player auto-restarts a MIDI at its",
7816 "last index if you move ZC Player out of focus, then back into focus.",
7817 "Proceed?",
7818 "&Yes",
7819 "&No",
7820 NULL,
7821 'y',
7822 'n',
7823 0,
7824 get_zc_font(font_lfont)) == 1)
7825 {
7826 midi_patch_fix = midi_patch_fix ? 0 : 1;
7827 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7828 }
7829 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7830 return D_O_K;
7831 }
7832
7833 int32_t onKeyboardEntry()
7834 {
7835 NameEntryMode=0;
7836 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7837 return D_O_K;
7838 }
7839
7840 int32_t onLetterGridEntry()
7841 {
7842 NameEntryMode=1;
7843 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7844 return D_O_K;
7845 }
7846
7847 int32_t onExtLetterGridEntry()
7848 {
7849 NameEntryMode=2;
7850 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7851 return D_O_K;
7852 }
7853
7854 static BITMAP* oldscreen;
7855 int32_t onFullscreenMenu()
7856 {
7857 // super hacks
7858 screen = oldscreen;
7859 if (onFullscreen() == D_REDRAW)
7860 {
7861 oldscreen = screen;
7862 }
7863 screen = menu_bmp;
7864 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7865 return D_O_K;
7866 }
7867
7868 33 void fix_menu()
7869 {
7870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!debug_enabled)
7871 33 settings_menu[13].text = NULL;
7872 33 }
7873
7874 static DIALOG system_dlg[] =
7875 {
7876 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7877 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7878 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7879 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7880 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7881 #ifndef ALLEGRO_MACOSX
7882 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7883 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7884 #else
7885 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7886 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7887 #endif
7888 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7889 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7890 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7891 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7892 };
7893
7894 void reset_snapshot_format_menu()
7895 {
7896 for(int32_t i=0; i<ssfmtMAX; ++i)
7897 {
7898 snapshot_format_menu[i].flags=0;
7899 }
7900 }
7901
7902 int32_t onSetSnapshotFormat()
7903 {
7904 switch(active_menu->text[1])
7905 {
7906 case 'B': //"&BMP"
7907 SnapshotFormat=0;
7908 break;
7909
7910 case 'G': //"&GIF"
7911 SnapshotFormat=1;
7912 break;
7913
7914 case 'J': //"&JPG"
7915 SnapshotFormat=2;
7916 break;
7917
7918 case 'P': //"&PNG"
7919 SnapshotFormat=3;
7920 break;
7921
7922 case 'C': //"PC&X"
7923 SnapshotFormat=4;
7924 break;
7925
7926 case 'T': //"&TGA"
7927 SnapshotFormat=5;
7928 break;
7929
7930 case 'L': //"&LBM"
7931 SnapshotFormat=6;
7932 break;
7933 }
7934 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7935
7936 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7937 return D_O_K;
7938 }
7939
7940
7941 47 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7942 {
7943 PALETTE tmp;
7944
7945
2/2
✓ Branch 0 taken 12032 times.
✓ Branch 1 taken 47 times.
12079 for(int32_t i=0; i<256; i++)
7946 {
7947 12032 tmp[i].r=r;
7948 12032 tmp[i].g=g;
7949 12032 tmp[i].b=b;
7950 12032 }
7951
7952 47 fade_interpolate(src,tmp,dest,pos,from,to);
7953 47 }
7954
7955 47 void system_pal()
7956 {
7957 47 is_sys_pal = true;
7958 static PALETTE pal;
7959 47 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7960
7961 // set up the grayscale palette
7962
2/2
✓ Branch 0 taken 3008 times.
✓ Branch 1 taken 47 times.
3055 for(int32_t i=128; i<192; i++)
7963 {
7964 3008 pal[i].r = i-128;
7965 3008 pal[i].g = i-128;
7966 3008 pal[i].b = i-128;
7967 3008 }
7968 47 load_colorset(gui_colorset, pal, jwin_a5_colors);
7969
7970 47 color_layer(pal, pal, 24,16,16, 28, 128,191);
7971
7972
2/2
✓ Branch 0 taken 6016 times.
✓ Branch 1 taken 47 times.
6063 for(int32_t i=0; i<256; i+=2)
7973 {
7974 6016 int32_t v = (i>>3)+2;
7975 6016 int32_t c = (i>>3)+192;
7976 6016 pal[c] = _RGB(v,v,v+(v>>1));
7977 /*
7978 if(i<240)
7979 {
7980 _allegro_hline(tmp_scr,0,i,319,c);
7981 _allegro_hline(tmp_scr,0,i+1,319,c);
7982 }
7983 */
7984 6016 }
7985
7986 // draw the vertical screen gradient
7987
2/2
✓ Branch 0 taken 11280 times.
✓ Branch 1 taken 47 times.
11327 for(int32_t i=0; i<240; ++i)
7988 {
7989 11280 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7990 11280 }
7991
7992 /*
7993 palrstart= 10*63/255; palrend=166*63/255;
7994 palgstart= 36*63/255; palgend=202*63/255;
7995 palbstart=106*63/255; palbend=240*63/255;
7996 paldivs=32;
7997 for(int32_t i=0; i<paldivs; i++)
7998 {
7999 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8000 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8001 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8002 }
8003 */
8004 47 BITMAP *panorama = create_bitmap_ex(8,256,224);
8005 int32_t ts_height, ts_start;
8006
8007
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8008 {
8009 clear_to_color(panorama,0);
8010 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8011 ts_height=224-passive_subscreen_height;
8012 ts_start=28;
8013 }
8014 else
8015 {
8016 47 blit(framebuf,panorama,0,0,0,0,256,224);
8017 47 ts_height=224;
8018 47 ts_start=0;
8019 }
8020
8021 // gray scale the current frame
8022
2/2
✓ Branch 0 taken 10528 times.
✓ Branch 1 taken 47 times.
10575 for(int32_t y=0; y<ts_height; y++)
8023 {
8024
2/2
✓ Branch 0 taken 2695168 times.
✓ Branch 1 taken 10528 times.
2705696 for(int32_t x=0; x<256; x++)
8025 {
8026 2695168 int32_t c = panorama->line[y+ts_start][x];
8027
2/2
✓ Branch 0 taken 2689245 times.
✓ Branch 1 taken 5923 times.
2695168 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8028 2695168 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8029 2695168 }
8030 10528 }
8031
8032 47 destroy_bitmap(panorama);
8033
8034 // display everything
8035 47 vsync();
8036 47 hw_palette = &pal;
8037 47 update_hw_pal = true;
8038
8039 // sys_pal = pal;
8040 47 memcpy(sys_pal,pal,sizeof(pal));
8041 47 }
8042
8043 void system_pal2()
8044 {
8045 is_sys_pal = true;
8046 static PALETTE RAMpal2;
8047 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8048
8049 /* Windows 2000 colors
8050 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8051 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8052 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8053 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8054 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8055 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8056 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8057 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8058
8059 byte palrstart= 10*63/255, palrend=166*63/255,
8060 palgstart= 36*63/255, palgend=202*63/255,
8061 palbstart=106*63/255, palbend=240*63/255,
8062 paldivs=7;
8063 for(int32_t i=0; i<paldivs; i++)
8064 {
8065 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8066 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8067 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8068 }
8069 */
8070
8071 /* Windows 98 colors
8072 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8073 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8074 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8075 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8076 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8077 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8078 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8079 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8080
8081 byte palrstart= 0*63/255, palrend=166*63/255,
8082 palgstart= 0*63/255, palgend=202*63/255,
8083 palbstart=128*63/255, palbend=240*63/255,
8084 paldivs=7;
8085 for(int32_t i=0; i<paldivs; i++)
8086 {
8087 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8088 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8089 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8090 }
8091 */
8092
8093 /* Windows 99 colors
8094 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8095 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8096 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8097 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8098 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8099 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8100 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8101 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8102 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8103
8104 byte palrstart= 0*63/255, palrend=166*63/255,
8105 palgstart= 0*63/255, palgend=202*63/255,
8106
8107 palbstart=128*63/255, palbend=240*63/255,
8108 paldivs=6;
8109 for(int32_t i=0; i<paldivs; i++)
8110 {
8111 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8112 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8113 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8114 }
8115 */
8116
8117
8118
8119 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8120 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8121 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8122 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8123 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8124 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8125 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8126 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8127 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8128
8129 byte palrstart= 0*63/255, palrend=166*63/255,
8130 palgstart= 0*63/255, palgend=202*63/255,
8131 palbstart=128*63/255, palbend=240*63/255,
8132 paldivs=6;
8133
8134 for(int32_t i=0; i<paldivs; i++)
8135 {
8136 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8137 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8138 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8139 }
8140
8141 gui_bg_color=jwin_pal[jcBOX];
8142 gui_fg_color=jwin_pal[jcBOXFG];
8143
8144 jwin_set_colors(jwin_pal);
8145
8146
8147 // set up the new palette
8148 for(int32_t i=128; i<192; i++)
8149 {
8150 RAMpal2[i].r = i-128;
8151 RAMpal2[i].g = i-128;
8152 RAMpal2[i].b = i-128;
8153 }
8154
8155 /*
8156 for(int32_t i=0; i<64; i++)
8157 {
8158 RAMpal2[128+i] = _RGB(i,i,i)1));
8159 }
8160 */
8161
8162 /*
8163
8164 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8165 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8166 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8167 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8168 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8169 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8170 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8171
8172 gui_fg_color=vc(14);
8173 gui_bg_color=vc(1);
8174
8175 jwin_set_colors(jwin_pal);
8176 */
8177
8178 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8179
8180 // set up the colors for the vertical screen gradient
8181 for(int32_t i=0; i<256; i+=2)
8182 {
8183 int32_t v = (i>>3)+2;
8184 int32_t c = (i>>3)+192;
8185 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8186
8187 /*
8188 if(i<240)
8189 {
8190 _allegro_hline(tmp_scr,0,i,319,c);
8191 _allegro_hline(tmp_scr,0,i+1,319,c);
8192 }
8193 */
8194 }
8195
8196 // hw_palette = &RAMpal;
8197 // update_hw_pal = true;
8198
8199 for(int32_t i=0; i<240; ++i)
8200 {
8201 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8202 }
8203
8204 /*
8205 byte palrstart= 10*63/255, palrend=166*63/255,
8206 palgstart= 36*63/255, palgend=202*63/255,
8207 palbstart=106*63/255, palbend=240*63/255,
8208 paldivs=32;
8209 for(int32_t i=0; i<paldivs; i++)
8210 {
8211 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8212 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8213 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8214 }
8215 */
8216 BITMAP *panorama = create_bitmap_ex(8,256,224);
8217 int32_t ts_height, ts_start;
8218
8219 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8220 {
8221 clear_to_color(panorama,0);
8222 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8223 ts_height=224-passive_subscreen_height;
8224 ts_start=28;
8225 }
8226 else
8227 {
8228 blit(framebuf,panorama,0,0,0,0,256,224);
8229 ts_height=224;
8230 ts_start=0;
8231 }
8232
8233 // gray scale the current frame
8234 for(int32_t y=0; y<ts_height; y++)
8235 {
8236 for(int32_t x=0; x<256; x++)
8237 {
8238 int32_t c = panorama->line[y+ts_start][x];
8239 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8240 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8241 }
8242 }
8243
8244 destroy_bitmap(panorama);
8245
8246 // display everything
8247 vsync();
8248 hw_palette = &RAMpal2;
8249 update_hw_pal = true;
8250
8251 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8252
8253 // sys_pal = pal;
8254 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8255 }
8256
8257 static uint32_t entered_sys_pal = 0;
8258 14 void enter_sys_pal()
8259 {
8260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8261 {
8262 if(entered_sys_pal)
8263 ++entered_sys_pal;
8264 return;
8265 }
8266 14 sys_mouse();
8267 14 system_pal();
8268 14 ++entered_sys_pal;
8269 14 }
8270 14 void exit_sys_pal()
8271 {
8272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8273 {
8274
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8275 {
8276 14 game_pal();
8277 14 game_mouse();
8278 14 }
8279 14 }
8280 14 }
8281
8282 void switch_out_callback()
8283 {
8284 if (pause_in_background)
8285 {
8286 callback_switchin = 3;
8287 return;
8288 }
8289
8290 #ifdef _WIN32
8291 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
8292 return;
8293
8294
8295 paused_midi_pos = midi_pos;
8296 zc_stop_midi();
8297 midi_paused=true;
8298 midi_suspended = midissuspHALTED;
8299 #endif
8300 }
8301
8302 void switch_in_callback()
8303 {
8304 if(pause_in_background)
8305 {
8306 return;
8307 }
8308
8309 #ifdef _WIN32
8310 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
8311 return;
8312
8313 else
8314 {
8315 callback_switchin = 1;
8316 midi_suspended = midissuspRESUME;
8317 }
8318 #endif
8319 }
8320
8321 342 void game_pal()
8322 {
8323 342 is_sys_pal = false;
8324 342 entered_sys_pal = 0;
8325 342 clear_to_color(screen,BLACK);
8326 342 hw_palette = &RAMpal;
8327 342 update_hw_pal = true;
8328 342 }
8329
8330 static char bar_str[] = "";
8331
8332 14 void music_pause()
8333 {
8334 //al_pause_duh(tmplayer);
8335 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8336 14 zc_midi_pause();
8337 14 midi_paused=true;
8338 14 }
8339
8340 void music_resume()
8341 {
8342 //al_resume_duh(tmplayer);
8343 zcmusic_pause(zcmusic, ZCM_RESUME);
8344 zc_midi_resume();
8345 midi_paused=false;
8346 }
8347
8348 6588 void music_stop()
8349 {
8350 //al_stop_duh(tmplayer);
8351 //unload_duh(tmusic);
8352 //tmusic=NULL;
8353 //tmplayer=NULL;
8354 6588 zcmusic_stop(zcmusic);
8355 6588 zcmusic_unload_file(zcmusic);
8356 6588 zc_stop_midi();
8357 6588 midi_paused=false;
8358 6588 currmidi=-1;
8359 6588 }
8360
8361 void System()
8362 {
8363 mouse_down=gui_mouse_b();
8364 music_pause();
8365 pause_all_sfx();
8366 MenuOpen = true;
8367 system_pal();
8368 // FONT *oldfont=font;
8369 // font=tfont;
8370
8371 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8372 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8373
8374 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8375 #if DEVLEVEL > 1
8376 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8377 #endif
8378 game_menu[3].flags =
8379 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8380 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8381 clear_keybuf();
8382 sys_mouse();
8383
8384 DIALOG_PLAYER *p;
8385
8386 clear_bitmap(menu_bmp);
8387 oldscreen = screen;
8388 screen = menu_bmp;
8389
8390 p = init_dialog(system_dlg,-1);
8391
8392 // drop the menu on startup if menu button pressed
8393 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8394 simulate_keypress(KEY_G << 8);
8395
8396 do
8397 {
8398 if(close_button_quit)
8399 {
8400 close_button_quit = false;
8401 f_Quit(qEXIT);
8402 if(Quit) break;
8403 }
8404 rest(17);
8405
8406 if(mouse_down && !gui_mouse_b())
8407 mouse_down=0;
8408
8409 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8410 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8411 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8412
8413 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8414 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8415 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8416 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8417 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8418 settings_menu[10].flags = NESquit?D_SELECTED:0;
8419 settings_menu[11].flags = volkeys?D_SELECTED:0;
8420
8421 window_menu[0].flags = DragAspect?D_SELECTED:0;
8422 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8423 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8424 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8425 window_menu[4].flags = stretchGame?D_SELECTED:0;
8426
8427 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8428 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8429
8430 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8431 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8432 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8433
8434 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8435 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8436 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8437 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8438
8439 bool nocheat = (replay_is_replaying() || !Playing
8440 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8441 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8442 cheat_menu[0].flags = 0;
8443 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8444 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8445 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8446 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8447 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8448 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8449 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8450 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8451 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8452
8453 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8454 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8455 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8456 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8457 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8458 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8459 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8460 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8461 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8462 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8463 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8464 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8465 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8466 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8467 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8468
8469 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8470 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8471
8472 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8473 (char *)"Disable recording new saves" :
8474 (char *)"Enable recording new saves";
8475 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8476 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8477 (char *)"Stop recording" :
8478 (char *)"Stop replaying";
8479 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8480 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8481 (char *)"Disable snapshot all frames" :
8482 (char *)"Enable snapshot all frames";
8483
8484 reset_snapshot_format_menu();
8485 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8486
8487 if(debug_enabled)
8488 {
8489 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8490 }
8491
8492 if(gui_mouse_b() && !mouse_down)
8493 break;
8494
8495 // press menu to drop the menu
8496 if(rMbtn())
8497 simulate_keypress(KEY_G << 8);
8498
8499 if(input_idle(true) > after_time())
8500 // run Screeen Saver
8501 {
8502 // Screen saver enabled for now.
8503 clear_keybuf();
8504 Matrix(ss_speed, ss_density, 0);
8505 system_pal();
8506 broadcast_dialog_message(MSG_DRAW, 0);
8507 }
8508
8509 update_hw_screen();
8510 }
8511 while(update_dialog(p));
8512
8513 screen = oldscreen;
8514
8515 // font=oldfont;
8516 mouse_down=gui_mouse_b();
8517 shutdown_dialog(p);
8518 game_mouse();
8519 MenuOpen = false;
8520 if(Quit)
8521 {
8522 kill_sfx();
8523 music_stop();
8524 update_hw_screen();
8525 }
8526 else
8527 {
8528 game_pal();
8529 music_resume();
8530 resume_all_sfx();
8531
8532 if(rc)
8533 ringcolor(false);
8534 }
8535
8536 eat_buttons();
8537
8538 rc=false;
8539 clear_keybuf();
8540 // text_mode(0);
8541 }
8542
8543 33 void fix_dialogs()
8544 {
8545 33 jwin_center_dialog(about_dlg);
8546 33 jwin_center_dialog(gamepad_dlg);
8547 33 jwin_center_dialog(credits_dlg);
8548 33 jwin_center_dialog(gamemode_dlg);
8549 33 jwin_center_dialog(getnum_dlg);
8550 33 jwin_center_dialog(goto_dlg);
8551 33 jwin_center_dialog(keyboard_control_dlg);
8552 33 jwin_center_dialog(midi_dlg);
8553 33 jwin_center_dialog(quest_dlg);
8554 33 jwin_center_dialog(scrsaver_dlg);
8555 33 jwin_center_dialog(sound_dlg);
8556 33 jwin_center_dialog(triforce_dlg);
8557
8558 // digi_dp[1] += scrx;
8559 // digi_dp[2] += scry;
8560 // midi_dp[1] += scrx;
8561 // midi_dp[2] += scry;
8562 // pan_dp[1] += scrx;
8563 // pan_dp[2] += scry;
8564 // emus_dp[1] += scrx;
8565 // emus_dp[2] += scry;
8566 // buf_dp[1] += scrx;
8567 // buf_dp[2] += scry;
8568 // sfx_dp[1] += scrx;
8569 // sfx_dp[2] += scry;
8570 33 }
8571
8572 /*****************************/
8573 /**** Custom Sound System ****/
8574 /*****************************/
8575
8576 2893 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8577 {
8578
3/4
✓ Branch 0 taken 2635 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2893 times.
✗ Branch 3 not taken.
2893 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8579 }
8580
8581 // Run an NSF, or a MIDI if the NSF is missing somehow.
8582 105 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8583 {
8584 105 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8585
8586 // Found it
8587
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 38 times.
105 if(newzcmusic!=NULL)
8588 {
8589 67 zcmusic_stop(zcmusic);
8590 67 zcmusic_unload_file(zcmusic);
8591 67 zc_stop_midi();
8592
8593 67 zcmusic=newzcmusic;
8594 67 zcmusic_play(zcmusic, emusic_volume);
8595
8596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(track>0)
8597 67 zcmusic_change_track(zcmusic,track);
8598
8599 67 return true;
8600 }
8601
8602 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8603
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 else if(midi>-1000)
8604 jukebox(midi);
8605
8606 38 return false;
8607 105 }
8608
8609 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8610 {
8611 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8612 // Found it
8613 if(newzcmusic!=NULL)
8614 {
8615 zcmusic_stop(zcmusic);
8616 zcmusic_unload_file(zcmusic);
8617 zc_stop_midi();
8618
8619 zcmusic=newzcmusic;
8620 zcmusic_play(zcmusic, emusic_volume);
8621
8622 if(track>0)
8623 zcmusic_change_track(zcmusic,track);
8624
8625 return true;
8626 }
8627
8628 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8629 else if(midi>-1000)
8630 jukebox(midi);
8631
8632 return false;
8633 }
8634
8635 int32_t get_zcmusicpos()
8636 {
8637 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8638 return debugtracething;
8639 return 0;
8640 }
8641
8642 void set_zcmusicpos(int32_t position)
8643 {
8644 zcmusic_set_curpos(zcmusic, position);
8645 }
8646
8647 void set_zcmusicspeed(int32_t speed)
8648 {
8649 int32_t newspeed = vbound(speed, 0, 10000);
8650 zcmusic_set_speed(zcmusic, newspeed);
8651 }
8652
8653 1430 void jukebox(int32_t index,int32_t loop)
8654 {
8655 1430 music_stop();
8656
8657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(index<0) index=MAXMIDIS-1;
8658
8659
1/2
✓ Branch 0 taken 1430 times.
✗ Branch 1 not taken.
1430 if(index>=MAXMIDIS) index=0;
8660
8661 1430 music_stop();
8662
8663 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8664 // stuck notes when a song stops. This fixes it.
8665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(strcmp(midi_driver->name, "DIGMID")==0)
8666 zc_set_volume(0, 0);
8667
8668 1430 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8669 1430 zc_play_midi((MIDI*)tunes[index].data,loop);
8670
8671
2/2
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 402 times.
1430 if(tunes[index].start>0)
8672 402 zc_midi_seek(tunes[index].start);
8673
8674 1430 midi_loop_start = tunes[index].loop_start;
8675 1430 midi_loop_end = tunes[index].loop_end;
8676
8677 1430 currmidi=index;
8678 1430 master_volume(digi_volume,midi_volume);
8679 1430 midi_paused=false;
8680 1430 }
8681
8682 11423 void jukebox(int32_t index)
8683 {
8684
1/2
✓ Branch 0 taken 11423 times.
✗ Branch 1 not taken.
11423 if(index<0) index=MAXMIDIS-1;
8685
8686
1/2
✓ Branch 0 taken 11423 times.
✗ Branch 1 not taken.
11423 if(index>=MAXMIDIS) index=0;
8687
8688 // do nothing if it's already playing
8689
3/4
✓ Branch 0 taken 9993 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 9993 times.
✗ Branch 3 not taken.
11423 if(index==currmidi && midi_pos>=0)
8690 {
8691 9993 midi_paused=false;
8692 9993 return;
8693 }
8694
8695 1430 jukebox(index,tunes[index].loop);
8696 11423 }
8697
8698 12753 void play_DmapMusic()
8699 {
8700 static char tfile[2048];
8701 static int32_t ttrack=0;
8702 12753 bool domidi=false;
8703
8704
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 11299 times.
12753 if(DMaps[currdmap].tmusic[0]!=0)
8705 {
8706
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1069 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1839 if(zcmusic==NULL ||
8707
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8708
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8709 {
8710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1069 times.
1069 if(zcmusic != NULL)
8711 {
8712 zcmusic_stop(zcmusic);
8713 zcmusic_unload_file(zcmusic);
8714 zcmusic = NULL;
8715 }
8716
8717 1069 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8718
8719
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 983 times.
1069 if(zcmusic!=NULL)
8720 {
8721 86 zc_stop_midi();
8722 86 strcpy(tfile,DMaps[currdmap].tmusic);
8723 86 zcmusic_play(zcmusic, emusic_volume);
8724 86 int32_t temptracks=0;
8725 86 temptracks=zcmusic_get_tracks(zcmusic);
8726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8727 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8728 86 zcmusic_change_track(zcmusic,ttrack);
8729 86 }
8730 else
8731 {
8732 983 tfile[0] = 0;
8733 983 domidi=true;
8734 }
8735 1069 }
8736 1454 }
8737 else
8738 {
8739 11299 domidi=true;
8740 }
8741
8742
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 12282 times.
12753 if(domidi)
8743 {
8744 12282 int32_t m=DMaps[currdmap].midi;
8745
8746
3/4
✓ Branch 0 taken 11875 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
12282 switch(m)
8747 {
8748 case 1:
8749 368 jukebox(ZC_MIDI_OVERWORLD);
8750 368 break;
8751
8752 case 2:
8753 39 jukebox(ZC_MIDI_DUNGEON);
8754 39 break;
8755
8756 case 3:
8757 jukebox(ZC_MIDI_LEVEL9);
8758 break;
8759
8760 default:
8761
3/4
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 1032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10843 times.
11875 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8762 10843 jukebox(m+MIDIOFFSET_DMAP);
8763 else
8764 1032 music_stop();
8765 11875 }
8766 12282 }
8767 12753 }
8768
8769 12791 void playLevelMusic()
8770 {
8771 12791 int32_t m=tmpscr->screen_midi;
8772
8773
3/6
✓ Branch 0 taken 12737 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
12791 switch(m)
8774 {
8775 case -2:
8776 13 music_stop();
8777 13 break;
8778
8779 case -1:
8780 12737 play_DmapMusic();
8781 12737 break;
8782
8783 case 1:
8784 jukebox(ZC_MIDI_OVERWORLD);
8785 break;
8786
8787 case 2:
8788 jukebox(ZC_MIDI_DUNGEON);
8789 break;
8790
8791 case 3:
8792 jukebox(ZC_MIDI_LEVEL9);
8793 break;
8794
8795 default:
8796
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8797 41 jukebox(m+MIDIOFFSET_MAPSCR);
8798 else
8799 music_stop();
8800 41 }
8801 12791 }
8802
8803 1463 void master_volume(int32_t dv,int32_t mv)
8804 {
8805
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1463 times.
✓ Branch 2 taken 1463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1463 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1463 times.
✗ Branch 7 not taken.
1463 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8806
8807
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1463 times.
✓ Branch 2 taken 1463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1463 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1463 times.
✗ Branch 7 not taken.
1463 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8808
8809
6/6
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 1461 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1423 times.
✓ Branch 5 taken 38 times.
1463 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8810 1463 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8811 1463 }
8812
8813 /*****************/
8814 /***** SFX *****/
8815 /*****************/
8816
8817 // array of voices, one for each sfx sample in the data file
8818 // 0+ = voice #
8819 // -1 = voice not allocated
8820 33 void Z_init_sound()
8821 {
8822
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 33 times.
8481 for(int32_t i=0; i<WAV_COUNT; i++)
8823 8448 sfx_voice[i]=-1;
8824
8825
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 33 times.
264 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8826 231 tunes[i].data = (MIDI*)mididata[i].dat;
8827
8828
2/2
✓ Branch 0 taken 8316 times.
✓ Branch 1 taken 33 times.
8349 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8829 8316 tunes[ZC_MIDI_COUNT+j].data=NULL;
8830
8831 33 master_volume(digi_volume,midi_volume);
8832 33 }
8833
8834 // returns number of voices currently allocated
8835 int32_t sfx_count()
8836 {
8837 int32_t c=0;
8838
8839 for(int32_t i=0; i<WAV_COUNT; i++)
8840 if(sfx_voice[i]!=-1)
8841 ++c;
8842
8843 return c;
8844 }
8845
8846 // clean up finished samples
8847 8085587 void sfx_cleanup()
8848 {
8849
2/2
✓ Branch 0 taken 2069910272 times.
✓ Branch 1 taken 8085587 times.
2077995859 for(int32_t i=0; i<WAV_COUNT; i++)
8850
3/4
✓ Branch 0 taken 634378 times.
✓ Branch 1 taken 2069275894 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 634378 times.
2070544650 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8851 {
8852 634378 deallocate_voice(sfx_voice[i]);
8853 634378 sfx_voice[i]=-1;
8854 634378 }
8855 8085587 }
8856
8857 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8858 // if a voice is already allocated (and/or playing), then it just returns true
8859 // Returns true: voice is allocated
8860 // false: unsuccessful
8861 974584 bool sfx_init(int32_t index)
8862 {
8863 // check index
8864
3/4
✓ Branch 0 taken 703299 times.
✓ Branch 1 taken 271285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 703299 times.
974584 if(index<=0 || index>=WAV_COUNT)
8865 271285 return false;
8866
8867
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 634405 times.
703299 if(sfx_voice[index]==-1)
8868 {
8869
2/2
✓ Branch 0 taken 182178 times.
✓ Branch 1 taken 452227 times.
634405 if(sfxdat)
8870 {
8871
1/2
✓ Branch 0 taken 182178 times.
✗ Branch 1 not taken.
182178 if(index<Z35)
8872 {
8873 182178 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8874 182178 }
8875 else
8876 {
8877 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8878 }
8879 182178 }
8880 else
8881 {
8882 452227 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8883 }
8884
8885 634405 voice_set_volume(sfx_voice[index], sfx_volume);
8886 634405 }
8887
8888 703299 return sfx_voice[index] != -1;
8889 974584 }
8890
8891 // plays an sfx sample
8892 829405 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8893 {
8894
2/2
✓ Branch 0 taken 630894 times.
✓ Branch 1 taken 198511 times.
829405 if(!sfx_init(index))
8895 198511 return;
8896
8897 630894 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8898 630894 voice_set_pan(sfx_voice[index],pan);
8899
8900 630894 int32_t pos = voice_get_position(sfx_voice[index]);
8901
8902
2/2
✓ Branch 0 taken 298046 times.
✓ Branch 1 taken 332848 times.
630894 if(restart) voice_set_position(sfx_voice[index],0);
8903
8904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630894 times.
630894 if(pos<=0)
8905 630894 voice_start(sfx_voice[index]);
8906
8907
3/4
✓ Branch 0 taken 332848 times.
✓ Branch 1 taken 298046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332848 times.
630894 if (restart && replay_is_debug())
8908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332848 times.
332848 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8909 829405 }
8910
8911 // true if sfx is allocated
8912 35405 bool sfx_allocated(int32_t index)
8913 {
8914
3/4
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 25998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9407 times.
35405 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8915 }
8916
8917 // start it (in loop mode) if it's not already playing,
8918 // otherwise adjust it to play in loop mode -DD
8919 145179 void cont_sfx(int32_t index)
8920 {
8921
2/2
✓ Branch 0 taken 72774 times.
✓ Branch 1 taken 72405 times.
145179 if(!sfx_init(index))
8922 {
8923 72774 return;
8924 }
8925
8926
1/2
✓ Branch 0 taken 72405 times.
✗ Branch 1 not taken.
72405 if(voice_get_position(sfx_voice[index])<=0)
8927 {
8928 72405 voice_set_position(sfx_voice[index],0);
8929 72405 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8930 72405 voice_start(sfx_voice[index]);
8931 72405 }
8932 else
8933 {
8934 adjust_sfx(index, 128, true);
8935 }
8936 145179 }
8937
8938 // adjust parameters while playing
8939 3961 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8940 {
8941
5/6
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2187 times.
3961 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8942 3947 return;
8943
8944 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8945 14 voice_set_pan(sfx_voice[index],pan);
8946 3961 }
8947
8948 // pauses a voice
8949 1651 void pause_sfx(int32_t index)
8950 {
8951
3/6
✓ Branch 0 taken 1651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1651 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1651 times.
1651 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8952 voice_stop(sfx_voice[index]);
8953 1651 }
8954
8955 // resumes a voice
8956 709 void resume_sfx(int32_t index)
8957 {
8958
3/6
✓ Branch 0 taken 709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 709 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 709 times.
709 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8959 voice_start(sfx_voice[index]);
8960 709 }
8961
8962 // pauses all active voices
8963 320 void pause_all_sfx()
8964 {
8965
2/2
✓ Branch 0 taken 81920 times.
✓ Branch 1 taken 320 times.
82240 for(int32_t i=0; i<WAV_COUNT; i++)
8966
2/2
✓ Branch 0 taken 81919 times.
✓ Branch 1 taken 1 times.
81921 if(sfx_voice[i]!=-1)
8967 1 voice_stop(sfx_voice[i]);
8968 320 }
8969
8970 // resumes all paused voices
8971 306 void resume_all_sfx()
8972 {
8973
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 306 times.
78642 for(int32_t i=0; i<WAV_COUNT; i++)
8974
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if(sfx_voice[i]!=-1)
8975 voice_start(sfx_voice[i]);
8976 306 }
8977
8978 // stops an sfx and deallocates the voice
8979 6474364 void stop_sfx(int32_t index)
8980 {
8981
3/4
✓ Branch 0 taken 5333163 times.
✓ Branch 1 taken 1141201 times.
✓ Branch 2 taken 5333163 times.
✗ Branch 3 not taken.
6474364 if(index<=0 || index>=WAV_COUNT)
8982 1141201 return;
8983
8984
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5333150 times.
5333163 if(sfx_voice[index]!=-1)
8985 {
8986 13 deallocate_voice(sfx_voice[index]);
8987 13 sfx_voice[index]=-1;
8988 13 }
8989 6474364 }
8990
8991 // Stops SFX played by Hero's item of the given family
8992 134717 void stop_item_sfx(int32_t family)
8993 {
8994 134717 int32_t id=current_item_id(family);
8995
8996
2/2
✓ Branch 0 taken 134251 times.
✓ Branch 1 taken 466 times.
134717 if(id<0)
8997 134251 return;
8998
8999 466 stop_sfx(itemsbuf[id].usesound);
9000 134717 }
9001
9002 2357 void kill_sfx()
9003 {
9004
2/2
✓ Branch 0 taken 603392 times.
✓ Branch 1 taken 2357 times.
605749 for(int32_t i=0; i<WAV_COUNT; i++)
9005
2/2
✓ Branch 0 taken 603378 times.
✓ Branch 1 taken 14 times.
603406 if(sfx_voice[i]!=-1)
9006 {
9007 14 deallocate_voice(sfx_voice[i]);
9008 14 sfx_voice[i]=-1;
9009 14 }
9010 2357 }
9011
9012 583542 int32_t pan(int32_t x)
9013 {
9014
1/4
✓ Branch 0 taken 583542 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
583542 switch(pan_style)
9015 {
9016 case 0:
9017 return 128;
9018
9019 case 1:
9020 583542 return vbound((x>>1)+68,0,255);
9021
9022 case 2:
9023 return vbound(((x*3)>>2)+36,0,255);
9024 }
9025
9026 return vbound(x,0,255);
9027 583542 }
9028
9029 /*******************************/
9030 /******* Input Handlers ********/
9031 /*******************************/
9032
9033 21804575 bool joybtn(int32_t b)
9034 {
9035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21804575 times.
21804575 if(b == 0)
9036 return false;
9037
9038 21804575 return joy[joystick_index].button[b-1].b !=0;
9039 21804575 }
9040
9041 const char* joybtn_name(int32_t b)
9042 {
9043 if(b == 0)
9044 return "";
9045
9046 return joy[joystick_index].button[b-1].name;
9047 }
9048
9049 int32_t next_press_key();
9050
9051 int32_t next_press_btn()
9052 {
9053 clear_keybuf();
9054 /*bool b[joy[joystick_index].num_buttons+1];
9055
9056 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9057 b[i]=joybtn(i);*/
9058
9059 //first, we need to wait until they're pressing no buttons
9060 for(;;)
9061 {
9062 if(keypressed())
9063 {
9064 switch(readkey()>>8)
9065 {
9066 case KEY_ESC:
9067 return -1;
9068
9069 case KEY_SPACE:
9070 return 0;
9071 }
9072 }
9073
9074 poll_joystick();
9075 bool done = true;
9076
9077 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9078 {
9079 if(joybtn(i)) done = false;
9080 }
9081
9082 if(done) break;
9083 rest(1);
9084 }
9085
9086 //now, we need to wait for them to press any button
9087 for(;;)
9088 {
9089 if(keypressed())
9090 {
9091 switch(readkey()>>8)
9092 {
9093 case KEY_ESC:
9094 return -1;
9095
9096 case KEY_SPACE:
9097 return 0;
9098 }
9099 }
9100
9101 poll_joystick();
9102
9103 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9104 {
9105 if(joybtn(i)) return i;
9106 }
9107 rest(1);
9108 }
9109 }
9110
9111 168538685 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9112 {
9113
2/2
✓ Branch 0 taken 162647457 times.
✓ Branch 1 taken 5891228 times.
168538685 bool ret = btn && !flag;
9114
2/2
✓ Branch 0 taken 142419089 times.
✓ Branch 1 taken 26119596 times.
168538685 flag = rawbtn ? *rawbtn : btn;
9115
9116 168538685 return ret;
9117 }
9118 1646643 static bool rButtonPeek(bool btn, bool flag)
9119 {
9120
2/2
✓ Branch 0 taken 1533938 times.
✓ Branch 1 taken 112705 times.
1646643 if(!btn)
9121 {
9122 1533938 return false;
9123 }
9124
2/2
✓ Branch 0 taken 16409 times.
✓ Branch 1 taken 96296 times.
112705 else if(!flag)
9125 {
9126 16409 return true;
9127 }
9128
9129 96296 return false;
9130 1646643 }
9131
9132 // Updated only by keyboard/gamepad.
9133 // If in replay mode, this is set directly by the replay system.
9134 // This should never be read from directly - use control_state instead.
9135 bool raw_control_state[ZC_CONTROL_STATES];
9136
9137 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9138 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9139 // lasts until the next call to load_control_state.
9140 bool control_state[ZC_CONTROL_STATES];
9141 bool disable_control[ZC_CONTROL_STATES];
9142 bool drunk_toggle_state[11];
9143 bool disabledKeys[127];
9144 bool KeyInput[127];
9145 bool KeyPress[127];
9146
9147 bool key_current_frame[127];
9148 bool key_previous_frame[127];
9149
9150 static bool key_system[127];
9151 static bool key_system_previous[127];
9152 static bool key_system_press[127];
9153
9154 bool button_press[ZC_CONTROL_STATES];
9155 bool button_hold[ZC_CONTROL_STATES];
9156
9157 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9158 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9159 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9160 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9161 #define STICK_PRECISION 56 //define your own sensitivity
9162
9163 6818528 void load_control_state()
9164 {
9165 6818528 load_control_called_this_frame = true;
9166
9167
4/4
✓ Branch 0 taken 3947327 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 1294575 times.
✓ Branch 3 taken 2652752 times.
6818528 if (replay_get_version() >= 8 && replay_get_version() < 11)
9168 {
9169
2/2
✓ Branch 0 taken 47749536 times.
✓ Branch 1 taken 2652752 times.
50402288 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9170 47749536 down_control_states[i] = raw_control_state[i];
9171 2652752 }
9172
9173
1/2
✓ Branch 0 taken 6818528 times.
✗ Branch 1 not taken.
6818528 if (!replay_is_replaying())
9174 {
9175 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9176 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9177 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9178 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9179 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9180 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9181 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9182 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9183 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9184 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9185 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9186 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9187 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9188 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9189
9190 if(num_joysticks != 0)
9191 {
9192 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9193 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9194 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9195 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9196 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9197 }
9198 else
9199 {
9200 raw_control_state[14] = false;
9201 raw_control_state[15] = false;
9202 raw_control_state[16] = false;
9203 raw_control_state[17] = false;
9204 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9205 }
9206 bool did_bad_cutscene_btn = false;
9207 for(int q = 0; q < 18; ++q)
9208 if(raw_control_state[q] && !active_cutscene.can_button(q))
9209 {
9210 raw_control_state[q] = false;
9211 did_bad_cutscene_btn = true;
9212 }
9213 if(did_bad_cutscene_btn)
9214 active_cutscene.error();
9215 }
9216
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6818525 times.
6818528 if (replay_is_active())
9217 {
9218
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5803310 times.
6818525 if (replay_get_version() < 3)
9219 1015215 replay_poll();
9220
3/4
✓ Branch 0 taken 5803310 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4041935 times.
✓ Branch 3 taken 1761375 times.
5803310 else if (replay_is_replaying() && replay_get_version() < 6)
9221 1761375 replay_peek_input();
9222
5/6
✓ Branch 0 taken 4041935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3947327 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 1294575 times.
✓ Branch 5 taken 2652752 times.
4041935 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9223 2652752 replay_peek_input();
9224
2/2
✓ Branch 0 taken 5713768 times.
✓ Branch 1 taken 1104757 times.
6818525 if (replay_get_version() == 8)
9225 1104757 update_keys();
9226 6818525 }
9227
9228 // Some test replay files were made before a serious input bug was fixed, so instead
9229 // of re-doing them or tossing them out, just check for that zplay version.
9230
3/4
✓ Branch 0 taken 6818522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6696622 times.
6818528 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9231
2/2
✓ Branch 0 taken 122733396 times.
✓ Branch 1 taken 6818522 times.
129551918 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9232 {
9233 122733396 control_state[i] = raw_control_state[i];
9234
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 73246086 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
122733396 if (botched_input && !control_state[i])
9235 47077142 down_control_states[i] = false;
9236 122733396 }
9237
9238 6818522 button_press[0]=rButton(control_state[0],button_hold[0]);
9239 6818522 button_press[1]=rButton(control_state[1],button_hold[1]);
9240 6818522 button_press[2]=rButton(control_state[2],button_hold[2]);
9241 6818522 button_press[3]=rButton(control_state[3],button_hold[3]);
9242 6818522 button_press[4]=rButton(control_state[4],button_hold[4]);
9243 6818522 button_press[5]=rButton(control_state[5],button_hold[5]);
9244 6818522 button_press[6]=rButton(control_state[6],button_hold[6]);
9245 6818522 button_press[7]=rButton(control_state[7],button_hold[7]);
9246 6818522 button_press[8]=rButton(control_state[8],button_hold[8]);
9247 6818522 button_press[9]=rButton(control_state[9],button_hold[9]);
9248 6818522 button_press[10]=rButton(control_state[10],button_hold[10]);
9249 6818522 button_press[11]=rButton(control_state[11],button_hold[11]);
9250 6818522 button_press[12]=rButton(control_state[12],button_hold[12]);
9251 6818522 button_press[13]=rButton(control_state[13],button_hold[13]);
9252 6818522 button_press[14]=rButton(control_state[14],button_hold[14]);
9253 6818522 button_press[15]=rButton(control_state[15],button_hold[15]);
9254 6818522 button_press[16]=rButton(control_state[16],button_hold[16]);
9255 6818522 button_press[17]=rButton(control_state[17],button_hold[17]);
9256 6818522 }
9257
9258 // Returns true if any game key is pressed. This is needed because keypressed()
9259 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9260 35392899 bool zc_key_pressed()
9261 //may also need to use zc_getrawkey
9262 {
9263
7/10
✓ Branch 0 taken 28675726 times.
✓ Branch 1 taken 6717173 times.
✓ Branch 2 taken 6717173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6717173 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5632865 times.
✓ Branch 7 taken 5632865 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2136415 times.
37529314 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9264
4/6
✓ Branch 0 taken 5632865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5632865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4266735 times.
✓ Branch 5 taken 4266735 times.
5632865 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9265
4/6
✓ Branch 0 taken 4266735 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4266735 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2755819 times.
✓ Branch 5 taken 2755819 times.
4266735 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9266
4/6
✓ Branch 0 taken 2755819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2755819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2389992 times.
✓ Branch 5 taken 2389992 times.
2755819 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9267
1/2
✓ Branch 0 taken 2389992 times.
✗ Branch 1 not taken.
2389992 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9268
3/4
✓ Branch 0 taken 2274024 times.
✓ Branch 1 taken 115968 times.
✓ Branch 2 taken 2274024 times.
✗ Branch 3 not taken.
2389992 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9269
3/4
✓ Branch 0 taken 2166107 times.
✓ Branch 1 taken 107917 times.
✓ Branch 2 taken 2166107 times.
✗ Branch 3 not taken.
2274024 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9270
3/4
✓ Branch 0 taken 2151616 times.
✓ Branch 1 taken 14491 times.
✓ Branch 2 taken 2151616 times.
✗ Branch 3 not taken.
2166107 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9271
3/4
✓ Branch 0 taken 2139038 times.
✓ Branch 1 taken 12578 times.
✓ Branch 2 taken 2139038 times.
✗ Branch 3 not taken.
2151616 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9272
3/4
✓ Branch 0 taken 2137294 times.
✓ Branch 1 taken 1744 times.
✓ Branch 2 taken 2137294 times.
✗ Branch 3 not taken.
2139038 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9273
3/4
✓ Branch 0 taken 2137221 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 2137221 times.
✗ Branch 3 not taken.
2137294 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9274
3/4
✓ Branch 0 taken 2136434 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 2136434 times.
✗ Branch 3 not taken.
2137221 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9275
2/4
✓ Branch 0 taken 2136434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2136434 times.
✗ Branch 3 not taken.
2136434 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9276
2/2
✓ Branch 0 taken 2136415 times.
✓ Branch 1 taken 19 times.
2136434 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9277 63347306 return true;
9278
9279 2136415 return false;
9280 8132269 }
9281
9282 133869767 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9283 {
9284 133869767 bool ret = false, drunkstate = false, rawret = false;
9285 133869767 bool* flag = &down_control_states[btn];
9286
2/7
✓ Branch 0 taken 125729005 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 8140762 times.
133869767 switch(btn)
9287 {
9288 case btnF12:
9289 ret = zc_getkey(KEY_F12, ignoreDisable);
9290 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9291 eatEntirely = false;
9292 break;
9293 case btnF11:
9294 ret = zc_getkey(KEY_F11, ignoreDisable);
9295 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9296 eatEntirely = false;
9297 break;
9298 case btnF5:
9299 ret = zc_getkey(KEY_F5, ignoreDisable);
9300 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9301 eatEntirely = false;
9302 break;
9303 case btnQ:
9304 ret = zc_getkey(KEY_Q, ignoreDisable);
9305 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9306 eatEntirely = false;
9307 break;
9308 case btnI:
9309 ret = zc_getkey(KEY_I, ignoreDisable);
9310 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9311 eatEntirely = false;
9312 break;
9313 case btnM:
9314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8140762 times.
8140762 if(FFCore.kb_typing_mode) return false;
9315 8140762 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9316 8140762 eatEntirely = false;
9317 8140762 break;
9318 default: //control_state[] index
9319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125729005 times.
125729005 if(FFCore.kb_typing_mode) return false;
9320
5/6
✓ Branch 0 taken 125258315 times.
✓ Branch 1 taken 470690 times.
✓ Branch 2 taken 2348400 times.
✓ Branch 3 taken 122909915 times.
✓ Branch 4 taken 2348400 times.
✗ Branch 5 not taken.
125729005 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9321
2/2
✓ Branch 0 taken 6791708 times.
✓ Branch 1 taken 118937297 times.
125729005 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9322
4/4
✓ Branch 0 taken 113325251 times.
✓ Branch 1 taken 12403754 times.
✓ Branch 2 taken 5048 times.
✓ Branch 3 taken 12398706 times.
138132759 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9323 125729005 rawret = raw_control_state[btn];
9324 125729005 }
9325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133869767 times.
133869767 assert(flag);
9326
2/2
✓ Branch 0 taken 86417835 times.
✓ Branch 1 taken 47451932 times.
133869767 if(press)
9327 {
9328
2/2
✓ Branch 0 taken 1646643 times.
✓ Branch 1 taken 45805289 times.
47451932 if(peek)
9329 1646643 ret = rButtonPeek(ret, *flag);
9330
3/4
✓ Branch 0 taken 45805289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26119596 times.
✓ Branch 3 taken 19685693 times.
45805289 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9331 26119596 else ret = rButton(ret, *flag, &rawret);
9332 47451932 }
9333
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133869767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133869767 if(eatEntirely && ret) control_state[btn] = false;
9334
3/4
✓ Branch 0 taken 101238710 times.
✓ Branch 1 taken 32631057 times.
✓ Branch 2 taken 101238710 times.
✗ Branch 3 not taken.
133869767 if(drunk && drunkstate) ret = !ret;
9335 133869767 return ret;
9336 133869767 }
9337
9338 6589258 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9339 {
9340 6589258 byte ret = 0;
9341
2/2
✓ Branch 0 taken 4940537 times.
✓ Branch 1 taken 1648721 times.
6589258 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9342
2/2
✓ Branch 0 taken 6588696 times.
✓ Branch 1 taken 562 times.
6589258 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9343
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9344
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9345
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9346
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9347
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9348
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9349 6589258 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9350 }
9351
9352 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9353 {
9354 1114 return intbtn&vals;
9355 }
9356
9357 1579380 bool Up()
9358 {
9359 1579380 return getInput(btnUp);
9360 }
9361 100763 bool Down()
9362 {
9363 100763 return getInput(btnDown);
9364 }
9365 193222 bool Left()
9366 {
9367 193222 return getInput(btnLeft);
9368 }
9369 217697 bool Right()
9370 {
9371 217697 return getInput(btnRight);
9372 }
9373 112761 bool cAbtn()
9374 {
9375 112761 return getInput(btnA);
9376 }
9377 1333347 bool cBbtn()
9378 {
9379 1333347 return getInput(btnB);
9380 }
9381 bool cSbtn()
9382 {
9383 return getInput(btnS);
9384 }
9385 46682 bool cLbtn()
9386 {
9387 46682 return getInput(btnL);
9388 }
9389 46682 bool cRbtn()
9390 {
9391 46682 return getInput(btnR);
9392 }
9393 bool cPbtn()
9394 {
9395 return getInput(btnP);
9396 }
9397 bool cEx1btn()
9398 {
9399 return getInput(btnEx1);
9400 }
9401 bool cEx2btn()
9402 {
9403 return getInput(btnEx2);
9404 }
9405 bool cEx3btn()
9406 {
9407 return getInput(btnEx3);
9408 }
9409 bool cEx4btn()
9410 {
9411 return getInput(btnEx4);
9412 }
9413 bool AxisUp()
9414 {
9415 return getInput(btnAxisUp);
9416 }
9417 bool AxisDown()
9418 {
9419 return getInput(btnAxisDown);
9420 }
9421 bool AxisLeft()
9422 {
9423 return getInput(btnAxisLeft);
9424 }
9425 bool AxisRight()
9426 {
9427 return getInput(btnAxisRight);
9428 }
9429
9430 bool cMbtn()
9431 {
9432 return getInput(btnM);
9433 }
9434 bool cF12()
9435 {
9436 return getInput(btnF12);
9437 }
9438 bool cF11()
9439 {
9440 return getInput(btnF11);
9441 }
9442 bool cF5()
9443 {
9444 return getInput(btnF5);
9445 }
9446 bool cQ()
9447 {
9448 return getInput(btnQ);
9449 }
9450 bool cI()
9451 {
9452 return getInput(btnI);
9453 }
9454
9455 127703 bool rUp()
9456 {
9457 127703 return getInput(btnUp, true);
9458 }
9459 127609 bool rDown()
9460 {
9461 127609 return getInput(btnDown, true);
9462 }
9463 127557 bool rLeft()
9464 {
9465 127557 return getInput(btnLeft, true);
9466 }
9467 127093 bool rRight()
9468 {
9469 127093 return getInput(btnRight, true);
9470 }
9471 2987 bool rAbtn()
9472 {
9473 2987 return getInput(btnA, true);
9474 }
9475 128823 bool rBbtn()
9476 {
9477 128823 return getInput(btnB, true);
9478 }
9479 6548031 bool rSbtn()
9480 {
9481 6548031 return getInput(btnS, true);
9482 }
9483 8132269 bool rMbtn()
9484 {
9485 8132269 return getInput(btnM, true);
9486 }
9487 126885 bool rLbtn()
9488 {
9489 126885 return getInput(btnL, true);
9490 }
9491 126880 bool rRbtn()
9492 {
9493 126880 return getInput(btnR, true);
9494 }
9495 6465204 bool rPbtn()
9496 {
9497 6465204 return getInput(btnP, true);
9498 }
9499 bool rEx1btn()
9500 {
9501 return getInput(btnEx1, true);
9502 }
9503 bool rEx2btn()
9504 {
9505 return getInput(btnEx2, true);
9506 }
9507 137531 bool rEx3btn()
9508 {
9509 137531 return getInput(btnEx3, true);
9510 }
9511 137531 bool rEx4btn()
9512 {
9513 137531 return getInput(btnEx4, true);
9514 }
9515 bool rAxisUp()
9516 {
9517 return getInput(btnAxisUp, true);
9518 }
9519 bool rAxisDown()
9520 {
9521 return getInput(btnAxisDown, true);
9522 }
9523 bool rAxisLeft()
9524 {
9525 return getInput(btnAxisLeft, true);
9526 }
9527 bool rAxisRight()
9528 {
9529 return getInput(btnAxisRight, true);
9530 }
9531
9532 bool rF11()
9533 {
9534 return getInput(btnF11, true);
9535 }
9536 bool rQ()
9537 {
9538 return getInput(btnQ, true);
9539 }
9540 bool rI()
9541 {
9542 return getInput(btnI, true);
9543 }
9544
9545 16396273 bool DrunkUp()
9546 {
9547 16396273 return getInput(btnUp, false, true);
9548 }
9549 15269213 bool DrunkDown()
9550 {
9551 15269213 return getInput(btnDown, false, true);
9552 }
9553 9598805 bool DrunkLeft()
9554 {
9555 9598805 return getInput(btnLeft, false, true);
9556 }
9557 8331926 bool DrunkRight()
9558 {
9559 8331926 return getInput(btnRight, false, true);
9560 }
9561 7131727 bool DrunkcAbtn()
9562 {
9563 7131727 return getInput(btnA, false, true);
9564 }
9565 7017752 bool DrunkcBbtn()
9566 {
9567 7017752 return getInput(btnB, false, true);
9568 }
9569 6418174 bool DrunkcEx1btn()
9570 {
9571 6418174 return getInput(btnEx1, false, true);
9572 }
9573 6418194 bool DrunkcEx2btn()
9574 {
9575 6418194 return getInput(btnEx2, false, true);
9576 }
9577 bool DrunkcSbtn()
9578 {
9579 return getInput(btnS, false, true);
9580 }
9581 bool DrunkcMbtn()
9582 {
9583 return getInput(btnM, false, true);
9584 }
9585 bool DrunkcLbtn()
9586 {
9587 return getInput(btnL, false, true);
9588 }
9589 bool DrunkcRbtn()
9590 {
9591 return getInput(btnR, false, true);
9592 }
9593 bool DrunkcPbtn()
9594 {
9595 return getInput(btnP, false, true);
9596 }
9597
9598 bool DrunkrUp()
9599 {
9600 return getInput(btnUp, true, true);
9601 }
9602 bool DrunkrDown()
9603 {
9604 return getInput(btnDown, true, true);
9605 }
9606 bool DrunkrLeft()
9607 {
9608 return getInput(btnLeft, true, true);
9609 }
9610 bool DrunkrRight()
9611 {
9612 return getInput(btnRight, true, true);
9613 }
9614 5376957 bool DrunkrAbtn()
9615 {
9616 5376957 return getInput(btnA, true, true);
9617 }
9618 5392619 bool DrunkrBbtn()
9619 {
9620 5392619 return getInput(btnB, true, true);
9621 }
9622 71669 bool DrunkrEx1btn()
9623 {
9624 71669 return getInput(btnEx1, true, true);
9625 }
9626 71662 bool DrunkrEx2btn()
9627 {
9628 71662 return getInput(btnEx2, true, true);
9629 }
9630 bool DrunkrEx3btn()
9631 {
9632 return getInput(btnEx3, true, true);
9633 }
9634 bool DrunkrEx4btn()
9635 {
9636 return getInput(btnEx4, true, true);
9637 }
9638 bool DrunkrSbtn()
9639 {
9640 return getInput(btnS, true, true);
9641 }
9642 bool DrunkrMbtn()
9643 {
9644 return getInput(btnM, true, true);
9645 }
9646 6047608 bool DrunkrLbtn()
9647 {
9648 6047608 return getInput(btnL, true, true);
9649 }
9650 6044226 bool DrunkrRbtn()
9651 {
9652 6044226 return getInput(btnR, true, true);
9653 }
9654 bool DrunkrPbtn()
9655 {
9656 return getInput(btnP, true, true);
9657 }
9658
9659 8493 void eat_buttons()
9660 {
9661 8493 getInput(btnA, true, false, true);
9662 8493 getInput(btnB, true, false, true);
9663 8493 getInput(btnS, true, false, true);
9664 8493 getInput(btnM, true, false, true);
9665 8493 getInput(btnL, true, false, true);
9666 8493 getInput(btnR, true, false, true);
9667 8493 getInput(btnP, true, false, true);
9668 8493 getInput(btnEx1, true, false, true);
9669 8493 getInput(btnEx2, true, false, true);
9670 8493 getInput(btnEx3, true, false, true);
9671 8493 getInput(btnEx4, true, false, true);
9672 8493 }
9673
9674 // Is true for the _first frame_ of a key press.
9675 // But! it is possible that a script manually sets the value of KeyPress,
9676 // in which case it will be restored to the "true" value based on `key_current_frame`
9677 // and `key_previous_frame` on the next frame.
9678 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9679 {
9680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9682 {
9683 case KEY_F7:
9684 case KEY_F8:
9685 case KEY_F9:
9686 return KeyPress[k];
9687
9688 default:
9689
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9690 }
9691 14 }
9692
9693 // Is true for _every frame_ a key is held down.
9694 // But! it is possible that a script manually sets the value of KeyInput,
9695 // in which case it will be restored to the "true" value based on `key_current_frame`
9696 // on the next frame.
9697 bool zc_getkey(int32_t k, bool ignoreDisable)
9698 {
9699 if(ignoreDisable) return KeyInput[k];
9700 switch(k)
9701 {
9702 case KEY_F7:
9703 case KEY_F8:
9704 case KEY_F9:
9705 return KeyInput[k];
9706
9707 default:
9708 return KeyInput[k] && !disabledKeys[k];
9709 }
9710 }
9711
9712 // Reads (and then clears) the current frame key state directly.
9713 // Scripts can also modify `key_current_frame`.
9714 202 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9715 {
9716
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 200 times.
202 if(zc_getrawkey(k, ignoreDisable))
9717 {
9718 2 _key[k]=key[k]=key_current_frame[k]=0;
9719 2 return true;
9720 }
9721 200 _key[k]=key[k]=key_current_frame[k]=0;
9722 200 return false;
9723 202 }
9724
9725 // Reads the current frame key state directly.
9726 // Scripts can also modify `key_current_frame`.
9727 55313985 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9728 {
9729
2/2
✓ Branch 0 taken 47181688 times.
✓ Branch 1 taken 8132297 times.
55313985 if(ignoreDisable) return key_current_frame[k];
9730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132297 times.
8132297 switch(k)
9731 {
9732 case KEY_F7:
9733 case KEY_F8:
9734 case KEY_F9:
9735 return key_current_frame[k];
9736
9737 default:
9738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132297 times.
8132297 return key_current_frame[k] && !disabledKeys[k];
9739 }
9740 55313985 }
9741
9742 // Only used for a handful of keys, like tilde and Function keys.
9743 // This state is never read within the game.
9744 // It exists so that all keyboard input still functions during replay,
9745 // without inadvertently doing things like toggling throttling if the player
9746 // presses ~
9747 16264636 bool zc_get_system_key(int32_t k)
9748 {
9749 16264636 return key_system[k];
9750 }
9751
9752 // True for the _first_ frame of a key press.
9753 73190421 bool zc_read_system_key(int32_t k)
9754 {
9755 73190421 return key_system_press[k];
9756 }
9757
9758 1032798163 bool is_system_key(int32_t k)
9759 {
9760
2/2
✓ Branch 0 taken 959607742 times.
✓ Branch 1 taken 73190421 times.
1032798163 switch (k)
9761 {
9762 case KEY_BACKQUOTE:
9763 case KEY_CLOSEBRACE:
9764 case KEY_END:
9765 case KEY_HOME:
9766 case KEY_OPENBRACE:
9767 case KEY_PGDN:
9768 case KEY_PGUP:
9769 case KEY_TAB:
9770 case KEY_TILDE:
9771 73190421 return true;
9772 }
9773 959607742 return is_Fkey(k);
9774 1032798163 }
9775
9776 8132269 void update_system_keys()
9777 {
9778
2/2
✓ Branch 0 taken 1032798163 times.
✓ Branch 1 taken 8132269 times.
1040930432 for (int32_t q = 0; q < 127; ++q)
9779 {
9780
2/2
✓ Branch 0 taken 170777649 times.
✓ Branch 1 taken 862020514 times.
1032798163 if (!is_system_key(q))
9781 862020514 continue;
9782
9783 170777649 key_system[q] = key[q];
9784
1/2
✓ Branch 0 taken 170777649 times.
✗ Branch 1 not taken.
170777649 key_system_press[q] = key_system[q] && !key_system_previous[q];
9785 170777649 key_system_previous[q] = key_system[q];
9786 170777649 }
9787 8132269 }
9788
9789 9237026 void update_keys()
9790 {
9791
2/2
✓ Branch 0 taken 1173102302 times.
✓ Branch 1 taken 9237026 times.
1182339328 for (int32_t q = 0; q < 127; ++q)
9792 {
9793 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9794
1/2
✓ Branch 0 taken 1173102302 times.
✗ Branch 1 not taken.
1173102302 if (!replay_is_replaying())
9795 key_current_frame[q] = key[q];
9796
9797
2/2
✓ Branch 0 taken 1164439575 times.
✓ Branch 1 taken 8662727 times.
1173102302 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9798 1173102302 KeyInput[q] = key_current_frame[q];
9799 1173102302 key_previous_frame[q] = key_current_frame[q];
9800 1173102302 }
9801 9237026 }
9802
9803 bool zc_disablekey(int32_t k, bool val)
9804 {
9805 switch(k)
9806 {
9807 case KEY_F7:
9808 case KEY_F8:
9809 case KEY_F9:
9810 return false;
9811
9812 default:
9813 disabledKeys[k] = val;
9814 return true;
9815 }
9816 }
9817
9818 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9819 {
9820 timer=timer;
9821 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9822 }
9823
9824 // these are here so that copy_dialog won't choke when compiling zelda
9825 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9826 {
9827 return D_O_K;
9828 }
9829
9830 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9831 {
9832 return D_O_K;
9833 }
9834
9835 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9836 {
9837 return D_O_K;
9838 }
9839
9840 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9841 {
9842 return D_O_K;
9843 }
9844
9845 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9846 {
9847 return D_O_K;
9848 }
9849
9850 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9851 {
9852 return D_O_K;
9853 }
9854
9855 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9856 {
9857 return D_O_K;
9858 }
9859
9860 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9861 {
9862 return D_O_K;
9863 }
9864
9865 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9866 {
9867 return D_O_K;
9868 }
9869
9870 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9871 {
9872 return D_O_K;
9873 }
9874
9875 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9876 {
9877 return D_O_K;
9878 }
9879
9880 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9881 {
9882 return D_O_K;
9883 }
9884
9885 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9886 {
9887 return D_O_K;
9888 }
9889
9890 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9891 {
9892 return D_O_K;
9893 }
9894
9895 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9896 {
9897 return D_O_K;
9898 }
9899
9900 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9901 {
9902 return D_O_K;
9903 }
9904
9905 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9906 {
9907 return D_O_K;
9908 }
9909
9910 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9911 {
9912 return D_O_K;
9913 }
9914
9915 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9916 {
9917 return D_O_K;
9918 }
9919
9920 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9921 {
9922 return D_O_K;
9923 }
9924
9925 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9926 {
9927 return D_O_K;
9928 }
9929
9930 /*** end of zc_sys.cc ***/
9931
9932